// Generated by Construct, the game and animation creation tool
// Visit: https://www.construct.net

// workers/domHandler.js
"use strict";window.DOMHandler=class{constructor(t,i){this._iRuntime=t,this._componentId=i,this._hasTickCallback=!1,this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(t,i,e,s){this._iRuntime.PostToRuntimeComponent(this._componentId,t,i,e,s)}PostToRuntimeAsync(t,i,e,s){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,t,i,e,s)}_PostToRuntimeMaybeSync(t,i,e){this._iRuntime.UsesWorker()?this.PostToRuntime(t,i,e):this._iRuntime._OnLocalRuntimeMessageFromDOM({"type":"event","component":this._componentId,"handler":t,"dispatchOpts":e||null,"data":i,"responseId":null})}AddRuntimeMessageHandler(t,i){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,t,i)}AddRuntimeMessageHandlers(t){for(const[i,e]of t)this.AddRuntimeMessageHandler(i,e)}GetRuntimeInterface(){return this._iRuntime}GetComponentID(){return this._componentId}_StartTicking(){this._hasTickCallback||(this._iRuntime._AddRAFCallback(this._tickCallback),this._hasTickCallback=!0)}_StopTicking(){this._hasTickCallback&&(this._iRuntime._RemoveRAFCallback(this._tickCallback),this._hasTickCallback=!1)}Tick(){}},window.RateLimiter=class{constructor(t,i){this._callback=t,this._interval=i,this._timerId=-1,this._lastCallTime=-1/0,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1}SetCanRunImmediate(t){this._canRunImmediate=!!t}Call(){if(-1!==this._timerId)return;const t=Date.now(),i=t-this._lastCallTime,e=this._interval;i>=e&&this._canRunImmediate?(this._lastCallTime=t,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(e-i,4))}_RunCallback(){this._ignoreReset=!0,this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._lastCallTime=Date.now())}_OnTimer(){this._timerId=-1,this._lastCallTime=Date.now(),this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer(),this._callback=null,this._timerCallFunc=null}};

// workers/domElementHandler.js
"use strict";{class e{constructor(e){this._elem=e,this._hadFirstUpdate=!1,this._isVisibleFlag=!0,this._wantHtmlIndex=-1,this._actualHtmlIndex=-1,this._htmlZIndex=-1}SetVisibleFlag(e){this._isVisibleFlag=!!e}GetVisibleFlag(){return this._isVisibleFlag}HadFirstUpdate(){return this._hadFirstUpdate}SetHadFirstUpdate(){this._hadFirstUpdate=!0}GetWantHTMLIndex(){return this._wantHtmlIndex}SetWantHTMLIndex(e){this._wantHtmlIndex=e}GetActualHTMLIndex(){return this._actualHtmlIndex}SetActualHTMLIndex(e){this._actualHtmlIndex=e}SetHTMLZIndex(e){this._htmlZIndex=e}GetHTMLZIndex(){return this._htmlZIndex}GetElement(){return this._elem}}window.DOMElementHandler=class extends self.DOMHandler{constructor(e,t){super(e,t),this._elementMap=new Map,this._autoAttach=!0,this.AddRuntimeMessageHandlers([["create",e=>this._OnCreate(e)],["destroy",e=>this._OnDestroy(e)],["set-visible",e=>this._OnSetVisible(e)],["update-position",e=>this._OnUpdatePosition(e)],["update-state",e=>this._OnUpdateState(e)],["focus",e=>this._OnSetFocus(e)],["set-css-style",e=>this._OnSetCssStyle(e)],["set-attribute",e=>this._OnSetAttribute(e)],["remove-attribute",e=>this._OnRemoveAttribute(e)]]),this.AddDOMElementMessageHandler("get-element",e=>e)}SetAutoAttach(e){this._autoAttach=!!e}AddDOMElementMessageHandler(e,t){this.AddRuntimeMessageHandler(e,e=>{const n=e["elementId"],s=this.GetElementById(n);return t(s,e)})}AddDOMElementMessageHandlers(e){for(const[t,n]of e)this.AddDOMElementMessageHandler(t,n)}_OnCreate(t){const n=t["elementId"],s=this.CreateElement(n,t),i=new e(s);this._elementMap.set(n,i),s.style.boxSizing="border-box",s.style.display="none",i.SetVisibleFlag(t["isVisible"]);const l=this._GetFocusElement(s);l.addEventListener("focus",e=>this._OnFocus(n)),l.addEventListener("blur",e=>this._OnBlur(n));const a=t["htmlIndex"];if(i.SetWantHTMLIndex(a),i.SetHTMLZIndex(t["htmlZIndex"]),this._autoAttach){const e=this.GetRuntimeInterface().GetAvailableHTMLIndex(a);i.SetActualHTMLIndex(e);this.GetRuntimeInterface().GetHTMLWrapElement(e).appendChild(s)}}CreateElement(e,t){throw new Error("required override")}DestroyElement(e){}_OnDestroy(e){const t=e["elementId"],n=this.GetElementById(t);this.DestroyElement(n),this._autoAttach&&n.parentElement.removeChild(n),this._elementMap.delete(t)}PostToRuntimeElement(e,t,n){n||(n={}),n["elementId"]=t,this.PostToRuntime(e,n)}_PostToRuntimeElementMaybeSync(e,t,n){n||(n={}),n["elementId"]=t,this._PostToRuntimeMaybeSync(e,n)}_OnSetVisible(e){if(!this._autoAttach)return;const t=this._elementMap.get(e["elementId"]),n=t.GetElement();t.HadFirstUpdate()?n.style.display=e["isVisible"]?"":"none":t.SetVisibleFlag(e["isVisible"])}_OnUpdatePosition(e){if(!this._autoAttach)return;const t=this._elementMap.get(e["elementId"]),n=t.GetElement(),s=this.GetRuntimeInterface();n.style.left=e["left"]+"px",n.style.top=e["top"]+"px",n.style.width=e["width"]+"px",n.style.height=e["height"]+"px";const i=e["fontSize"];null!==i&&(n.style.fontSize=i+"em");const l=e["htmlIndex"];t.SetWantHTMLIndex(l);const a=s.GetAvailableHTMLIndex(l);if(a!==t.GetActualHTMLIndex()){n.remove();s.GetHTMLWrapElement(a).appendChild(n),t.SetActualHTMLIndex(a),s._UpdateHTMLElementsZOrder()}const d=e["htmlZIndex"];d!==t.GetHTMLZIndex()&&(t.SetHTMLZIndex(d),s._UpdateHTMLElementsZOrder()),t.HadFirstUpdate()||(t.SetHadFirstUpdate(),t.GetVisibleFlag()&&(n.style.display=""))}_OnHTMLLayersChanged(){if(this._autoAttach)for(const e of this._elementMap.values()){const t=this.GetRuntimeInterface().GetAvailableHTMLIndex(e.GetWantHTMLIndex()),n=e.GetActualHTMLIndex();if(-1!==t&&-1!==n&&t!==n){const n=e.GetElement();n.remove();this.GetRuntimeInterface().GetHTMLWrapElement(t).appendChild(n),e.SetActualHTMLIndex(t)}}}_GetAllElementStatesForZOrderUpdate(){return this._autoAttach?[...this._elementMap.values()]:null}_OnUpdateState(e){const t=this.GetElementById(e["elementId"]);this.UpdateState(t,e)}UpdateState(e,t){throw new Error("required override")}_GetFocusElement(e){return e}_OnFocus(e){this.PostToRuntimeElement("elem-focused",e)}_OnBlur(e){this.PostToRuntimeElement("elem-blurred",e)}_OnSetFocus(e){const t=this._GetFocusElement(this.GetElementById(e["elementId"]));e["focus"]?t.focus():t.blur()}_OnSetCssStyle(e){const t=this.GetElementById(e["elementId"]),n=e["prop"],s=e["val"];n.startsWith("--")?t.style.setProperty(n,s):t.style[n]=s}_OnSetAttribute(e){this.GetElementById(e["elementId"]).setAttribute(e["name"],e["val"])}_OnRemoveAttribute(e){this.GetElementById(e["elementId"]).removeAttribute(e["name"])}GetElementById(e){const t=this._elementMap.get(e);if(!t)throw new Error(`no element with id ${e}`);return t.GetElement()}}}

// workers/domSide.js
"use strict";{const e=/(iphone|ipod|ipad|macos|macintosh|mac os x)/i.test(navigator.userAgent),t=/android/i.test(navigator.userAgent),s=/safari/i.test(navigator.userAgent)&&!/(chrome|chromium|edg\/|OPR\/)/i.test(navigator.userAgent);let n=0;function r(e){const t=document.createElement("script");return t.async=!1,t.type="module",e.isStringSrc?new Promise(s=>{const r="c3_resolve_"+n;++n,self[r]=s,t.textContent=e.str+`\n\nself["${r}"]();`,document.head.appendChild(t)}):new Promise((s,n)=>{t.onload=s,t.onerror=n,t.src=e,document.head.appendChild(t)})}async function i(){if(!navigator["userActivation"]||"undefined"==typeof OffscreenCanvas)return!1;try{let e=!1;const t=new Blob(['\n\tself.addEventListener("message", () =>\n\t{\n\t\ttry {\n\t\t\tconst offscreenCanvas = new OffscreenCanvas(32, 32);\n\t\t\tconst gl = offscreenCanvas.getContext("webgl");\n\t\t\tself.postMessage(!!gl);\n\t\t}\n\t\tcatch (err)\n\t\t{\n\t\t\tconsole.warn("Feature detection worker error:", err);\n\t\t\tself.postMessage(false);\n\t\t}\n\t});'],{"type":"text/javascript"}),s=new Worker(URL.createObjectURL(t),{get type(){e=!0}}),n=await new Promise(e=>{s.addEventListener("message",t=>{s.terminate(),e(t.data)}),s.postMessage("")});return e&&n}catch(e){return console.warn("Error feature detecting worker mode: ",e),!1}}let a=new Audio;const o={"audio/webm; codecs=opus":!!a.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!a.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!a.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!a.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!a.canPlayType("audio/mp4"),"audio/mpeg":!!a.canPlayType("audio/mpeg")};a=null;window["RealFile"]=window["File"];const l=[],d=new Map,c=new Map;let p=0;const h=[];self.runOnStartup=function(e){if("function"!=typeof e)throw new Error("runOnStartup called without a function");h.push(e)};const m=new Set(["cordova","playable-ad-single-file","playable-ad-zip","instant-games"]);function u(e){return m.has(e)}let w=!1;window.RuntimeInterface=class n{#e=!0;#t=null;#s="";#n="";#r=null;#i=null;#a=[];#o=null;#l=!0;#d=[];#c=[];#p=!1;#h=()=>this.#m();#u=!1;#w=0;#y=null;#g=-1;#f=()=>this.#v();#b=new Set;#M=null;#T=[];#C=[];#R="";constructor(e){if(this.#e=e.useWorker,this.#n=e.scriptFolder,this.#R=e.exportType,"playable-ad-single-file"!==this.#R&&"playable-ad-zip"!==this.#R&&"instant-games"!==this.#R||(this.#e=!1),(s||"macos-wkwebview"===this.#R)&&(this.#e=!1),"cordova"===this.#R&&this.#e&&t){const e=/Chrome\/(\d+)/i.exec(navigator.userAgent);e&&parseInt(e[1],10)>=90||(this.#e=!1)}this.IsAnyWebView2Wrapper()?self["chrome"]["webview"].addEventListener("message",e=>this.#I(e.data,e["additionalObjects"])):"macos-wkwebview"===this.#R?self["C3WrapperOnMessage"]=e=>this.#I(JSON.parse(e)):"linux-cef"===this.#R&&self["c3_linux_cef_set_message_callback"](e=>this.#I(JSON.parse(e))),this._localFileBlobs=null,this._localFileStrings=null,"html5"!==this.#R||window.isSecureContext||console.warn("[Construct] Warning: the browser indicates this is not a secure context. Some features may be unavailable. Use secure (HTTPS) hosting to ensure all features are available."),this.AddRuntimeComponentMessageHandler("canvas","update-size",e=>this.#S(e)),this.AddRuntimeComponentMessageHandler("canvas","set-html-layer-count",e=>this["_OnSetHTMLLayerCount"](e)),this.AddRuntimeComponentMessageHandler("canvas","cleanup-html-layers",()=>this.#L()),this.AddRuntimeComponentMessageHandler("canvas","update-html-layer-dom-state",e=>this.#P(e["layersDomState"])),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",e=>this.#O(e)),this.AddRuntimeComponentMessageHandler("runtime","send-wrapper-extension-message",e=>this.#W(e)),this.AddRuntimeComponentMessageHandler("runtime","send-raw-wrapper-extension-message",e=>this.#H(e)),"cordova"===this.#R?document.addEventListener("deviceready",()=>this.#x(e)):this.#x(e),this._skipAndroidVirtualKeyboardDetection=0}Release(){this._CancelAnimationFrame(),this.#t&&(this.#t.onmessage=null,this.#t=null),this.#r&&(this.#r.terminate(),this.#r=null),this.#i&&(this.#i.Release(),this.#i=null);for(const{canvas:e,htmlWrap:t}of this.#d)e.remove(),t.remove();this.#d.length=0}GetMainCanvas(){return this.#d[0].canvas}GetAvailableHTMLIndex(e){return Math.min(e,this.#d.length-1)}GetHTMLWrapElement(e){if(e<0||e>=this.#d.length)throw new RangeError("invalid canvas layer");return this.#d[e].htmlWrap}"_GetHTMLWrapElement"(e){return this.GetHTMLWrapElement(e)}GetRuntimeBaseURL(){return this.#s}UsesWorker(){return this.#e}GetExportType(){return this.#R}GetScriptFolder(){return this.#n}IsiOSCordova(){return e&&"cordova"===this.#R}IsiOSWebView(){const t=navigator.userAgent;return e&&u(this.#R)||navigator["standalone"]||/crios\/|fxios\/|edgios\//i.test(t)}IsAndroid(){return t}IsAndroidWebView(){return t&&u(this.#R)}IsWindowsWebView2(){return"windows-webview2"===this.#R||!!("preview"===this.#R&&window["chrome"]&&window["chrome"]["webview"]&&window["chrome"]["webview"]["postMessage"])}IsAnyWebView2Wrapper(){return this.IsWindowsWebView2()||"xbox-uwp-webview2"===this.#R}SkipNextAndroidVirtualKeyboardDetection(){this.IsAndroidWebView()&&this._skipAndroidVirtualKeyboardDetection++}CanDoAndroidVirtualKeyboardDetection(){return this._CanDoAndroidVirtualKeyboardDetection().next().value}*_CanDoAndroidVirtualKeyboardDetection(){if(!this.IsAndroidWebView())return!0;yield 0===this._skipAndroidVirtualKeyboardDetection,this._skipAndroidVirtualKeyboardDetection>0&&this._skipAndroidVirtualKeyboardDetection--}async#x(e){if(this.#e){await i()||(this.#e=!1)}if("macos-wkwebview"===this.#R&&this._SendWrapperMessage({"type":"ready"}),this.IsAnyWebView2Wrapper()||"macos-wkwebview"===this.#R||"linux-cef"===this.#R){this.#k();const e=await this.#A();this.#T=e["registeredComponentIds"]}if("playable-ad-single-file"===this.#R&&(this._localFileBlobs=self["c3_base64files"],this._localFileStrings={},await this.#_()),e.runtimeBaseUrl)this.#s=e.runtimeBaseUrl;else{const e=location.origin;this.#s=("null"===e?"file:///":e)+location.pathname;const t=this.#s.lastIndexOf("/");-1!==t&&(this.#s=this.#s.substr(0,t+1))}const t=new MessageChannel;if(this.#t=t.port1,this.#t.onmessage=e=>this["_OnMessageFromRuntime"](e.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"](e=>this.#E(e)),this.#y=new self.JobSchedulerDOM(this),await this.#y.Init(),"object"==typeof window["StatusBar"]&&window["StatusBar"]["hide"](),"object"==typeof window["AndroidFullScreen"])try{await new Promise((e,t)=>{window["AndroidFullScreen"]["immersiveMode"](e,t)})}catch(e){console.error("Failed to enter Android immersive mode: ",e)}this.#e?await this.#D(e,t.port2):await this.#F(e,t.port2)}#U(e){return{"runtimeBaseUrl":this.#s,"previewUrl":location.href,"windowInnerWidth":this._GetWindowInnerWidth(),"windowInnerHeight":this._GetWindowInnerHeight(),"cssDisplayMode":this.GetCssDisplayMode(),"devicePixelRatio":window.devicePixelRatio,"isFullscreen":n.IsDocumentFullscreen(),"swClientId":window["cr_swClientId"]||"","exportType":e.exportType,"fileMap":globalThis.c3_swFileMap??new Map(Object.entries(this._localFileBlobs??{})),"scriptFolder":this.#n,"isDebug":new URLSearchParams(self.location.search).has("debug"),"ife":!!self.ife,"jobScheduler":this.#y.GetPortData(),"supportedAudioFormats":o,"isiOSCordova":this.IsiOSCordova(),"isiOSWebView":this.IsiOSWebView(),"isWindowsWebView2":this.IsWindowsWebView2(),"isAnyWebView2Wrapper":this.IsAnyWebView2Wrapper(),"wrapperComponentIds":this.#T,"isFBInstantAvailable":void 0!==self["FBInstant"]}}async#D(e,t){const s=e.workerMainUrl;"preview"===this.#R?(this.#r=new Worker("previewworker.js",{type:"module",name:"Runtime"}),await new Promise((e,t)=>{const n=s=>{this.#r.removeEventListener("message",n),s.data&&"ok"===s.data["type"]?e():t()};this.#r.addEventListener("message",n),this.#r.postMessage({"type":"construct-worker-init","import":new URL(s,this.#s).toString()})})):this.#r=await this.CreateWorker(s,{type:"module",name:"Runtime"});const n=document.createElement("canvas");n.style.display="none";const r=n["transferControlToOffscreen"]();document.body.appendChild(n);const i=document.createElement("div");i.className="c3htmlwrap",i.setAttribute("interactive",""),document.body.appendChild(i),this.#d.push({canvas:n,htmlWrap:i,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=n,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this.#r.postMessage(Object.assign(this.#U(e),{"type":"init-runtime","isInWorker":!0,"messagePort":t,"canvas":r,"runtimeScriptList":e.runtimeScriptList,"projectMainScriptPath":e.projectMainScriptPath,"javaScriptInEventsPath":e.javaScriptInEventsPath,"typeScriptInEventsPath":e.typeScriptInEventsPath}),[t,r,...this.#y.GetPortTransferables()]),this.#a=l.map(e=>new e(this)),this.#B(),this.#o._AddDefaultCanvasEventHandlers(n),this.#o._AddDefaultHTMLWrapEventHandlers(i),this.#o._EnableWindowResizeEvent(),self["c3_callFunction"]=(e,t)=>this.#o._InvokeFunctionFromJS(e,t),"preview"===this.#R&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async#F(e,t){const s=document.createElement("canvas");s.style.display="none",document.body.appendChild(s);const n=document.createElement("div");n.className="c3htmlwrap",n.setAttribute("interactive",""),document.body.appendChild(n),this.#d.push({canvas:s,htmlWrap:n,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}}),window["c3canvas"]=s,self["C3_InsertHTMLPlaceholders"]&&self["C3_InsertHTMLPlaceholders"](),this.#a=l.map(e=>new e(this)),this.#B(),this.#o._AddDefaultCanvasEventHandlers(s),this.#o._AddDefaultHTMLWrapEventHandlers(n);const i=await Promise.all(e.runtimeScriptList.map(e=>this.#G(e)));await Promise.all(i.map(e=>r(e)));const a=e.projectMainScriptPath,o=e.javaScriptInEventsPath,d=e.typeScriptInEventsPath;if(a)try{if(await r(a),"preview"===this.#R&&!globalThis.C3_ProjectMainScriptOK)throw new Error("main script did not run to completion")}catch(e){this.#V(),console.error("Error loading project main script: ",e),alert(`Failed to load the project main script (${a}). Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the script. Press F12 and check the console for error details.`)}if(o)try{if(await r(o),"preview"===this.#R&&!globalThis.C3.JavaScriptInEvents)throw new Error("JavaScript in events did not run to completion")}catch(e){this.#V(),console.error("Error loading JavaScript in events: ",e),alert("Failed to load JavaScript in events. Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}if(d)try{if(await r(d),"preview"===this.#R&&!globalThis.C3.TypeScriptInEvents)throw new Error("TypeScript in events did not run to completion")}catch(e){this.#V(),console.error("Error loading TypeScript in events: ",e),alert("Failed to load TypeScript in events. Check all your TypeScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}const c=Object.assign(this.#U(e),{"isInWorker":!1,"messagePort":t,"canvas":s,"runOnStartupFunctions":h});this.#o._EnableWindowResizeEvent(),this.#j(),this.#i=self["C3_CreateRuntime"](c),await self["C3_InitRuntime"](this.#i,c)}async CreateWorker(e,t){if(e.startsWith("blob:"))return new Worker(e,t);if("playable-ad-single-file"===this.#R){const s=this._localFileBlobs[e];if(!s)throw new Error("missing script: "+e);return new Worker(URL.createObjectURL(s),t)}const s=new URL(e,location.href);if(location.origin!==s.origin){const e=await fetch(s);if(!e.ok)throw new Error("failed to fetch worker script");const n=await e.blob();return new Worker(URL.createObjectURL(n),t)}return new Worker(s,t)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,1)}GetCssDisplayMode(){if(this.IsAnyWebView2Wrapper())return"standalone";const e=this.GetExportType();return new Set(["cordova","macos-wkwebview","linux-cef"]).has(e)?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: minimal-ui)").matches?"minimal-ui":navigator["standalone"]?"standalone":"browser"}#j(){this.#V()}#V(){const e=window["cr_previewLoadingElem"];e&&(e.parentElement.removeChild(e),window["cr_previewLoadingElem"]=null)}async#O(e){const t=await this.#y._CreateJobWorker();return{"outputPort":t,"transferables":[t]}}#S(e){if(this.IsExportingToVideo())return;const t=e["styleWidth"]+"px",s=e["styleHeight"]+"px",n=e["marginLeft"]+"px",r=e["marginTop"]+"px";for(const{canvas:e,htmlWrap:i}of this.#d)e.style.width=t,e.style.height=s,e.style.marginLeft=n,e.style.marginTop=r,i.style.width=t,i.style.height=s,i.style.marginLeft=n,i.style.marginTop=r,this.#l&&(e.style.display="",i.style.display="");document.documentElement.style.setProperty("--construct-scale",e["displayScale"]),this.#l=!1}"_OnSetHTMLLayerCount"(e){const t=e["count"],s=e["layersDomState"],n=e["immediate"],r=e["styleWidth"]+"px",i=e["styleHeight"]+"px",a=e["marginLeft"]+"px",o=e["marginTop"]+"px",l=[],d=[];if(t<this.#d.length)for(;this.#d.length>t;){const{canvas:e,htmlWrap:t}=this.#d.pop();t.remove(),this.#e&&!n?this.#c.push(e):e.remove()}else if(t>this.#d.length)for(let e=0,s=t-this.#d.length;e<s;++e){const e=document.createElement("canvas");if(e.classList.add("c3overlay"),this.#e){const t=e["transferControlToOffscreen"]();l.push(t),d.push(t)}else l.push(e);document.body.appendChild(e);const t=document.createElement("div");t.classList.add("c3htmlwrap","c3overlay"),t.setAttribute("interactive",""),document.body.appendChild(t),e.style.width=r,e.style.height=i,e.style.marginLeft=a,e.style.marginTop=o,t.style.width=r,t.style.height=i,t.style.marginLeft=a,t.style.marginTop=o,this.#o._AddDefaultCanvasEventHandlers(e),this.#o._AddDefaultHTMLWrapEventHandlers(t),this.#d.push({canvas:e,htmlWrap:t,lastHtmlLayerDomState:{isVisible:!0,opacity:1,isInteractive:!0}})}this.#P(s);for(const e of this.#a)e instanceof window.DOMElementHandler&&e._OnHTMLLayersChanged();return this._UpdateHTMLElementsZOrder(),{"addedCanvases":l,"transferables":d}}#P(e){for(let t=0,s=Math.min(this.#d.length,e.length);t<s;++t){const{htmlWrap:s,lastHtmlLayerDomState:n}=this.#d[t],r=e[t],i=r["isVisible"],a=r["opacity"],o=r["isInteractive"];i!==n.isVisible&&(s.style.display=i?"":"none",n.isVisible=i),a!==n.opacity&&(s.style.opacity=1===a?"":String(a),n.opacity=a),o!==n.isInteractive&&(s.style.pointerEvents=o?"":"none",o?s.setAttribute("interactive",""):s.removeAttribute("interactive"),n.isInteractive=o)}}#L(){for(const e of this.#c)e.remove();this.#c.length=0}_UpdateHTMLElementsZOrder(){this.#p||(this.#p=!0,this._AddRAFCallback(this.#h))}#m(){this._RemoveRAFCallback(this.#h),this.#p=!1;let e=[];for(const t of this.#a)if(t instanceof window.DOMElementHandler){const s=t._GetAllElementStatesForZOrderUpdate();s&&e.push(...s)}e.sort((e,t)=>{const s=e.GetActualHTMLIndex(),n=t.GetActualHTMLIndex();if(s!==n)return s-n;return e.GetHTMLZIndex()-t.GetHTMLZIndex()});let t=0,s=0,n=0,r=e.length;for(;n<r;++n){const r=e[n];r.GetActualHTMLIndex()!==t&&(this.#z(t,e.slice(s,n)),t=r.GetActualHTMLIndex(),s=n)}s<n&&this.#z(t,e.slice(s,n))}#z(e,t){if(t.length<=1)return;if(e>=this.#d.length)return;const s=t.map(e=>e.GetElement()),n=new Set(s),r=this.GetHTMLWrapElement(e),i=Array.from(r.children).filter(e=>n.has(e));for(let e=0,t=0,n=s.length;e<n;++e){const n=s[e],a=i[t];n===a?++t:r["moveBefore"]?r["moveBefore"](n,a):r.insertBefore(n,a)}}_OnLocalRuntimeMessageFromDOM(e){if(this.#e)throw new Error("not available in worker mode");this.#i["_OnMessageFromDOM"](e)}PostToRuntimeComponent(e,t,s,n,r){this.#t.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":n||null,"data":s,"responseId":null},r)}PostToRuntimeComponentAsync(e,t,s,n,r){const i=p++,a=new Promise((e,t)=>{c.set(i,{resolve:e,reject:t})});return this.#t.postMessage({"type":"event","component":e,"handler":t,"dispatchOpts":n||null,"data":s,"responseId":i},r),a}"_OnMessageFromRuntime"(e){const t=e["type"];if("event"===t)return this.#Z(e);if("result"===t)this.#J(e);else if("runtime-ready"===t)this.#$();else if("alert-error"===t)this.#V(),alert(e["message"]);else{if("creating-runtime"!==t)throw new Error(`unknown message '${t}'`);this.#j()}}#Z(e){const t=e["component"],s=e["handler"],n=e["data"],r=e["responseId"],i=d.get(t);if(!i)return void console.warn(`[DOM] No event handlers for component '${t}'`);const a=i.get(s);if(!a)return void console.warn(`[DOM] No handler '${s}' for component '${t}'`);let o=null;try{o=a(n)}catch(e){return console.error(`Exception in '${t}' handler '${s}':`,e),void(null!==r&&this.#q(r,!1,""+e))}if(null===r)return o;o&&o.then?o.then(e=>this.#q(r,!0,e)).catch(e=>{console.error(`Rejection from '${t}' handler '${s}':`,e),this.#q(r,!1,""+e)}):this.#q(r,!0,o)}#q(e,t,s){let n;s&&s["transferables"]&&(n=s["transferables"]),this.#t.postMessage({"type":"result","responseId":e,"isOk":t,"result":s},n)}#J(e){const t=e["responseId"],s=e["isOk"],n=e["result"],r=c.get(t);s?r.resolve(n):r.reject(n),c.delete(t)}AddRuntimeComponentMessageHandler(e,t,s){let n=d.get(e);if(n||(n=new Map,d.set(e,n)),n.has(t))throw new Error(`[DOM] Component '${e}' already has handler '${t}'`);n.set(t,s)}static AddDOMHandlerClass(e){if(l.includes(e))throw new Error("DOM handler already added");l.push(e)}#B(){for(const e of this.#a)if("runtime"===e.GetComponentID())return void(this.#o=e);throw new Error("cannot find runtime DOM handler")}#E(e){this.PostToRuntimeComponent("debugger","message",e)}#$(){for(const e of this.#a)e.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"]||w)}static _SetWrapperIsFullscreenFlag(e){w=!!e}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(e){this.#b.add(e),this._RequestAnimationFrame()}_RemoveRAFCallback(e){this.#b.delete(e),0===this.#b.size&&this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this.#g&&this.#b.size>0&&(this.#g=requestAnimationFrame(this.#f))}_CancelAnimationFrame(){-1!==this.#g&&(cancelAnimationFrame(this.#g),this.#g=-1)}#v(){this.#g=-1;for(const e of this.#b)e();this._RequestAnimationFrame()}TryPlayMedia(e){this.#o.TryPlayMedia(e)}RemovePendingPlay(e){this.#o.RemovePendingPlay(e)}_PlayPendingMedia(){this.#o._PlayPendingMedia()}AddAnyGamepadInputCallback(e){this.#o._AddAnyGamepadInputCallback(e)}RemoveAnyGamepadInputCallback(e){this.#o._RemoveAnyGamepadInputCallback(e)}SetSilent(e){this.#o.SetSilent(e)}IsAudioFormatSupported(e){return!!o[e]}SetIsExportingToVideo(e){this.#u=!0,this.#w=e}IsExportingToVideo(){return this.#u}GetExportToVideoDuration(){return this.#w}IsAbsoluteURL(e){return/^(?:[a-z\-]+:)?\/\//.test(e)||"data:"===e.substr(0,5)||"blob:"===e.substr(0,5)}IsRelativeURL(e){return!this.IsAbsoluteURL(e)}async#G(e){if("playable-ad-single-file"===this.#R){if(this._localFileStrings.hasOwnProperty(e))return{isStringSrc:!0,str:this._localFileStrings[e]};if(this._localFileBlobs.hasOwnProperty(e))return URL.createObjectURL(this._localFileBlobs[e]);throw new Error("missing script: "+e)}return e}"_PlayableAdFetchBlob"(e){if(this._localFileBlobs.hasOwnProperty(e))return this._localFileBlobs[e];throw new Error("missing file: "+e)}#K(){const e=window["cordova"]&&window["cordova"]["plugins"]&&window["cordova"]["plugins"]["permissions"];if("object"!=typeof e)throw new Error("Permission API is not loaded");return e}#N(e,t){const s=e[t];if("string"!=typeof s)throw new Error("Invalid permission name");return s}#X(e){const t=this.#K();return new Promise((s,n)=>t["checkPermission"](this.#N(t,e),e=>s(!!e["hasPermission"]),n))}#Y(e){const t=this.#K();return new Promise((s,n)=>t["requestPermission"](this.#N(t,e),e=>s(!!e["hasPermission"]),n))}async RequestPermissions(e){if("cordova"!==this.GetExportType())return!0;if(this.IsiOSCordova())return!0;for(const t of e){if(await this.#X(t))continue;if(!1===await this.#Y(t))return!1}return!0}async RequirePermissions(...e){if(!1===await this.RequestPermissions(e))throw new Error("Permission not granted")}#I(e,t){if("object"!=typeof e||!e)return void console.warn("Unknown wrapper message: ",e);const s=e["type"];if("directory-handles"===s)this.#C=t;else if("wrapper-init-response"===s)this.#M(e),this.#M=null;else if("fullscreen-change"===s)n._SetWrapperIsFullscreenFlag(e["isFullscreen"]),this.#o._OnFullscreenChange();else if("log-to-console"===s)switch(e["logType"]){case"error":console.error(e["message"]);break;case"warning":console.warn(e["message"]);break;default:console.log(e["message"])}else if("window-maximized"==s||"window-minimized"==s){const e={"window-maximized":"windowmaximize","window-minimized":"windowminimize"};this.PostToRuntimeComponent("runtime",e[s],null,{"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0})}else"extension-message"===s?this.PostToRuntimeComponent("runtime","wrapper-extension-message",e):console.warn("Unknown wrapper message: ",e)}#W(e){this._SendWrapperMessage({"type":"extension-message","componentId":e["componentId"],"messageId":e["messageId"],"params":e["params"]||[],"asyncId":e["asyncId"]})}#H(e){this._SendWrapperMessage(e)}_SendWrapperMessage(e){this.IsAnyWebView2Wrapper()?window["chrome"]["webview"]["postMessage"](JSON.stringify(e)):"macos-wkwebview"===this.#R?window["webkit"]["messageHandlers"]["C3Wrapper"]["postMessage"](JSON.stringify(e)):"linux-cef"===this.#R&&window["c3_linux_cef_sendmessage"](JSON.stringify(e))}#k(){window.moveTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-position","windowX":Math.ceil(e),"windowY":Math.ceil(t)})},window.resizeTo=(e,t)=>{this._SendWrapperMessage({"type":"set-window-size","windowWidth":Math.ceil(e),"windowHeight":Math.ceil(t)})},window.focus=()=>{this._SendWrapperMessage({"type":"focus-window"})}}#A(){return new Promise(e=>{this.#M=e,this._SendWrapperMessage({"type":"wrapper-init"})})}_GetDirectoryHandles(){return this.#C}async#_(){const e=[];for(const[t,s]of Object.entries(this._localFileBlobs))e.push(this.#Q(t,s));await Promise.all(e)}async#Q(e,t){if("object"==typeof t)this._localFileBlobs[e]=new Blob([t["str"]],{"type":t["type"]}),this._localFileStrings[e]=t["str"];else{let s=await this.#ee(t);s||(s=this.#te(t)),this._localFileBlobs[e]=s}}async#ee(e){try{const t=await fetch(e);return await t.blob()}catch(e){return console.warn("Failed to fetch a data: URI. Falling back to a slower workaround. This is probably because the Content Security Policy unnecessarily blocked it. Allow data: URIs in your CSP to avoid this.",e),null}}#te(e){const t=this.#se(e);return this.#ne(t.data,t.mime_type)}#se(e){const t=e.indexOf(",");if(t<0)throw new URIError("expected comma in data: uri");const s=e.substring(5,t),n=e.substring(t+1),r=s.split(";"),i=r[0]||"",a=r[1],o=r[2];let l;return l="base64"===a||"base64"===o?atob(n):decodeURIComponent(n),{mime_type:i,data:l}}#ne(e,t){let s,n,r=e.length,i=r>>2,a=new Uint8Array(r),o=new Uint32Array(a.buffer,0,i);for(s=0,n=0;s<i;++s)o[s]=e.charCodeAt(n++)|e.charCodeAt(n++)<<8|e.charCodeAt(n++)<<16|e.charCodeAt(n++)<<24;let l=3&r;for(;l--;)a[n]=e.charCodeAt(n),++n;return new Blob([a],{"type":t})}}}

// workers/runtimeDomEvents.js
"use strict";{const e=self.RuntimeInterface,t=/firefox/i.test(navigator.userAgent);function i(e){return e["sourceCapabilities"]&&e["sourceCapabilities"]["firesTouchEvents"]||e["originalEvent"]&&e["originalEvent"]["sourceCapabilities"]&&e["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}const n=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),s={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},o={"dispatchUserScriptEvent":!0},a={"dispatchRuntimeEvent":!0};async function d(e){const t=URL.createObjectURL(e);try{return await(i=t,new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=i}))}finally{URL.revokeObjectURL(t)}var i}function r(e){do{if(e.parentNode&&e.hasAttribute("contenteditable"))return!0;e=e.parentNode}while(e);return!1}const l=new Set(["input","textarea","datalist","select"]);const c=new Set(["canvas","body","html"]);function h(e){if(!e.target.tagName)return;const t=e.target.tagName.toLowerCase();c.has(t)&&e.preventDefault()}function m(e){e.target.tagName&&e.target.classList.contains("c3htmlwrap")&&e.preventDefault()}function u(e){(e.metaKey||e.ctrlKey)&&e.preventDefault()}self["C3_GetSvgImageSize"]=async function(e){const t=await d(e);if(t.width>0&&t.height>0)return[t.width,t.height];{t.style.position="absolute",t.style.left="0px",t.style.top="0px",t.style.visibility="hidden",document.body.appendChild(t);const e=t.getBoundingClientRect();return document.body.removeChild(t),[e.width,e.height]}},self["C3_RasterSvgImageBlob"]=async function(e,t,i,n,s){const o=await d(e),a=document.createElement("canvas");a.width=n,a.height=s;return a.getContext("2d").drawImage(o,0,0,t,i),a};let p=!1;function g(){try{return window.parent&&window.parent.document.hasFocus()}catch(e){return!1}}document.addEventListener("pause",()=>p=!0),document.addEventListener("resume",()=>p=!1);const _="runtime",w=class extends self.DOMHandler{constructor(e){super(e,_),this._enableWindowResizeEvent=!1,this._simulatedResizeTimerId=-1,this._targetOrientation="any",this._attachedDeviceOrientationEvent=!1,this._attachedDeviceMotionEvent=!1,this._pageVisibilityIsHidden=!1,this._isPollingGamepads=!1,this._pollGamepadRafCallback=()=>this._OnPollGamepads(),this._gamepadInputCallbacks=new Set,this._screenReaderTextWrap=document.createElement("div"),this._screenReaderTextWrap.className="c3-screen-reader-text",this._screenReaderTextWrap.setAttribute("aria-live","polite"),document.body.appendChild(this._screenReaderTextWrap),this._debugHighlightElem=null,this._isExportToVideo=!1,this._exportVideoProgressMessage="",this._exportVideoUpdateTimerId=-1,this._enableAndroidVKDetection=!1,this._lastWindowWidth=e._GetWindowInnerWidth(),this._lastWindowHeight=e._GetWindowInnerHeight(),this._virtualKeyboardHeight=0,this._vkTranslateYOffset=0,e.AddRuntimeComponentMessageHandler("runtime","invoke-download",e=>this._OnInvokeDownload(e)),e.AddRuntimeComponentMessageHandler("runtime","load-webfonts",e=>this._OnLoadWebFonts(e)),e.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",e=>this._OnRasterSvgImage(e)),e.AddRuntimeComponentMessageHandler("runtime","get-svg-image-size",e=>this._OnGetSvgImageSize(e)),e.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",e=>this._OnSetTargetOrientation(e)),e.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW()),e.AddRuntimeComponentMessageHandler("runtime","post-to-debugger",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","go-to-script",e=>this._OnPostToDebugger(e)),e.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking()),e.AddRuntimeComponentMessageHandler("runtime","debug-highlight",e=>this._OnDebugHighlight(e)),e.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent()),e.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",()=>this._AttachDeviceMotionEvent()),e.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",e=>this._OnAddStylesheet(e)),e.AddRuntimeComponentMessageHandler("runtime","script-create-worker",e=>this._OnScriptCreateWorker(e)),e.AddRuntimeComponentMessageHandler("runtime","alert",e=>this._OnAlert(e)),e.AddRuntimeComponentMessageHandler("runtime","screen-reader-text",e=>this._OnScreenReaderTextEvent(e)),e.AddRuntimeComponentMessageHandler("runtime","hide-cordova-splash",()=>this._OnHideCordovaSplash()),e.AddRuntimeComponentMessageHandler("runtime","set-exporting-to-video",e=>this._SetExportingToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","export-to-video-progress",e=>this._OnExportVideoProgress(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-video",e=>this._OnExportedToVideo(e)),e.AddRuntimeComponentMessageHandler("runtime","exported-to-image-sequence",e=>this._OnExportedToImageSequence(e));const t=new Set(["input","textarea","datalist"]);if(window.addEventListener("contextmenu",e=>{const i=e.target,n=i.tagName.toLowerCase();t.has(n)||r(i)||e.preventDefault()}),window.addEventListener("selectstart",h),window.addEventListener("gesturehold",h),window.addEventListener("touchstart",h,{"passive":!1}),window.addEventListener("pointerdown",h,{"passive":!1}),this._mousePointerLastButtons=0,window.addEventListener("mousedown",e=>{1===e.button&&e.preventDefault()}),window.addEventListener("mousewheel",u,{"passive":!1}),window.addEventListener("wheel",u,{"passive":!1}),window.addEventListener("resize",()=>this._OnWindowResize()),window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("mozfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("fullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("webkitfullscreenerror",e=>this._OnFullscreenError(e)),window.addEventListener("mozfullscreenerror",e=>this._OnFullscreenError(e)),e.IsiOSWebView()){let e=1/0;window["visualViewport"].addEventListener("resize",()=>{const t=window["visualViewport"].height;t>e&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0),e=t}),document.documentElement.setAttribute("ioswebview","")}this._mediaPendingPlay=new Set,this._mediaRemovedPendingPlay=new WeakSet,this._isSilent=!1}_AddDefaultCanvasEventHandlers(e){e.addEventListener("selectstart",h),e.addEventListener("gesturehold",h),e.addEventListener("pointerdown",h)}_AddDefaultHTMLWrapEventHandlers(e){e.addEventListener("selectstart",m),e.addEventListener("gesturehold",m),e.addEventListener("touchstart",m),e.addEventListener("dragstart",m)}_OnBeforeStartTicking(){return self.setTimeout(()=>{this._enableAndroidVKDetection=!0},1e3),"cordova"===this._iRuntime.GetExportType()?(document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1))):document.addEventListener("visibilitychange",()=>this._OnVisibilityChange("hidden"===document.visibilityState)),this._pageVisibilityIsHidden=!("hidden"!==document.visibilityState&&!p),{"isSuspended":this._pageVisibilityIsHidden}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus")),window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":g()}),this._mousePointerLastButtons=0}),window.addEventListener("focusin",e=>{var t;t=e.target,(l.has(t.tagName.toLowerCase())||r(t))&&this._PostRuntimeEvent("keyboard-blur")}),window.addEventListener("keydown",e=>this._OnKeyEvent("keydown",e)),window.addEventListener("keyup",e=>this._OnKeyEvent("keyup",e)),window.addEventListener("mousedown",e=>this._OnMouseEvent("mousedown",e,o)),window.addEventListener("mousemove",e=>this._OnMouseEvent("mousemove",e,o)),window.addEventListener("mouseup",e=>this._OnMouseEvent("mouseup",e,o)),window.addEventListener("dblclick",e=>this._OnMouseEvent("dblclick",e,s)),window.addEventListener("wheel",e=>this._OnMouseWheelEvent("wheel",e,s)),window.addEventListener("pointerdown",e=>{this._HandlePointerDownFocus(e),this._OnPointerEvent("pointerdown",e)}),this._iRuntime.UsesWorker()&&void 0!==window["onpointerrawupdate"]&&self===self.top&&!t?window.addEventListener("pointerrawupdate",e=>this._OnPointerRawUpdate(e)):window.addEventListener("pointermove",e=>this._OnPointerEvent("pointermove",e)),window.addEventListener("pointerup",e=>this._OnPointerEvent("pointerup",e)),window.addEventListener("pointercancel",e=>this._OnPointerEvent("pointercancel",e));const e=()=>this._PlayPendingMedia();window.addEventListener("pointerup",e,!0),window.addEventListener("touchend",e,!0),window.addEventListener("click",e,!0),window.addEventListener("keydown",e,!0),navigator.getGamepads().some(e=>!!e)&&(this._iRuntime._AddRAFCallback(this._pollGamepadRafCallback),this._isPollingGamepads=!0),window.addEventListener("gamepadconnected",()=>this._OnGamepadConnected(),!0),window.addEventListener("gamepaddisconnected",()=>this._OnGamepadDisconnected(),!0),this._iRuntime.IsAndroid()&&!this._iRuntime.IsAndroidWebView()&&navigator["virtualKeyboard"]&&(navigator["virtualKeyboard"]["overlaysContent"]=!0,navigator["virtualKeyboard"].addEventListener("geometrychange",()=>{this._OnAndroidVirtualKeyboardChange(this._GetWindowInnerHeight(),navigator["virtualKeyboard"]["boundingRect"]["height"])})),this._iRuntime.IsiOSWebView()&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0)}_OnAndroidVirtualKeyboardChange(e,t){if(document.body.style.position="",document.body.style.overflow="",document.body.style.transform="",this._vkTranslateYOffset=0,t>0){const i=document.activeElement;if(i){const n=i.getBoundingClientRect();let s=(n.top+n.bottom)/2-(e-t)/2;s>t&&(s=t),s<0&&(s=0),s>0&&(document.body.style.position="absolute",document.body.style.overflow="visible",document.body.style.transform=`translateY(${-s}px)`,this._vkTranslateYOffset=s)}}}_PostRuntimeEvent(e,t){this.PostToRuntime(e,t||null,a)}_GetWindowInnerWidth(){return this._iRuntime._GetWindowInnerWidth()}_GetWindowInnerHeight(){return this._iRuntime._GetWindowInnerHeight()}_EnableWindowResizeEvent(){this._enableWindowResizeEvent=!0,this._lastWindowWidth=this._iRuntime._GetWindowInnerWidth(),this._lastWindowHeight=this._iRuntime._GetWindowInnerHeight()}_OnWindowResize(){if(this._isExportToVideo)return;if(!this._enableWindowResizeEvent)return;const t=this._GetWindowInnerWidth(),i=this._GetWindowInnerHeight();if(this._iRuntime.IsAndroidWebView())if(this._enableAndroidVKDetection){if(this._iRuntime.CanDoAndroidVirtualKeyboardDetection()&&this._lastWindowWidth===t&&i<this._lastWindowHeight)return this._virtualKeyboardHeight=this._lastWindowHeight-i,void this._OnAndroidVirtualKeyboardChange(this._lastWindowHeight,this._virtualKeyboardHeight);this._virtualKeyboardHeight>0&&(this._virtualKeyboardHeight=0,this._OnAndroidVirtualKeyboardChange(i,this._virtualKeyboardHeight)),this._lastWindowWidth=t,this._lastWindowHeight=i}else this._lastWindowWidth=t,this._lastWindowHeight=i;this.PostToRuntime("window-resize",{"innerWidth":t,"innerHeight":i,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":e.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}),this._iRuntime.IsiOSWebView()&&(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(t,i,0))}_ScheduleSimulatedResize(e,t,i){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(e,t,i),48)}_OnSimulatedResize(t,i,n){const s=this._GetWindowInnerWidth(),o=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1,s!=t||o!=i?this.PostToRuntime("window-resize",{"innerWidth":s,"innerHeight":o,"devicePixelRatio":window.devicePixelRatio,"isFullscreen":e.IsDocumentFullscreen(),"cssDisplayMode":this._iRuntime.GetCssDisplayMode()}):n<10&&this._ScheduleSimulatedResize(s,o,n+1)}_OnSetTargetOrientation(e){this._targetOrientation=e["targetOrientation"]}_TrySetTargetOrientation(){const e=this._targetOrientation;if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](e).catch(e=>console.warn("[Construct] Failed to lock orientation: ",e));else try{let t=!1;screen["lockOrientation"]?t=screen["lockOrientation"](e):screen["webkitLockOrientation"]?t=screen["webkitLockOrientation"](e):screen["mozLockOrientation"]?t=screen["mozLockOrientation"](e):screen["msLockOrientation"]&&(t=screen["msLockOrientation"](e)),t||console.warn("[Construct] Failed to lock orientation")}catch(e){console.warn("[Construct] Failed to lock orientation: ",e)}}_OnFullscreenChange(){if(this._isExportToVideo)return;const t=e.IsDocumentFullscreen();t&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation(),this.PostToRuntime("fullscreenchange",{"isFullscreen":t,"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnFullscreenError(t){console.warn("[Construct] Fullscreen request failed: ",t),this.PostToRuntime("fullscreenerror",{"isFullscreen":e.IsDocumentFullscreen(),"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnVisibilityChange(e){if(this._pageVisibilityIsHidden!==e&&(this._pageVisibilityIsHidden=e,e?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame(),this.PostToRuntime("visibilitychange",{"hidden":e}),!e&&this._iRuntime.IsiOSWebView())){const e=()=>{document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0};setTimeout(e,50),setTimeout(e,100),setTimeout(e,250),setTimeout(e,500)}}_OnKeyEvent(e,t){if(void 0===t.key)return;if("Backspace"===t.key&&h(t),this._isExportToVideo)return;const i=n.get(t.code)||t.code;this._PostToRuntimeMaybeSync(e,{"code":i,"key":t.key,"which":t.which,"repeat":t.repeat,"altKey":t.altKey,"ctrlKey":t.ctrlKey,"metaKey":t.metaKey,"shiftKey":t.shiftKey,"timeStamp":t.timeStamp},s)}_OnMouseWheelEvent(e,t,i){this._isExportToVideo||this.PostToRuntime(e,{"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"deltaX":t.deltaX,"deltaY":t.deltaY,"deltaZ":t.deltaZ,"deltaMode":t.deltaMode,"timeStamp":t.timeStamp},i)}_OnMouseEvent(e,t,n){this._isExportToVideo||i(t)||this._PostToRuntimeMaybeSync(e,{"button":t.button,"buttons":t.buttons,"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"timeStamp":t.timeStamp},n)}_OnPointerEvent(e,t){if(this._isExportToVideo)return;let i=0;"mouse"===t.pointerType&&(i=this._mousePointerLastButtons),this._PostToRuntimeMaybeSync(e,{"pointerId":t.pointerId,"pointerType":t.pointerType,"button":t.button,"buttons":t.buttons,"lastButtons":i,"clientX":t.clientX,"clientY":t.clientY+this._vkTranslateYOffset,"pageX":t.pageX,"pageY":t.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"width":t.width||0,"height":t.height||0,"pressure":t.pressure||0,"tangentialPressure":t["tangentialPressure"]||0,"tiltX":t.tiltX||0,"tiltY":t.tiltY||0,"twist":t["twist"]||0,"timeStamp":t.timeStamp},s),"mouse"===t.pointerType&&(this._mousePointerLastButtons=t.buttons)}_OnPointerRawUpdate(e){this._OnPointerEvent("pointermove",e)}_OnTouchEvent(e,t){if(!this._isExportToVideo)for(let i=0,n=t.changedTouches.length;i<n;++i){const n=t.changedTouches[i];this._PostToRuntimeMaybeSync(e,{"pointerId":n.identifier,"pointerType":"touch","button":0,"buttons":0,"lastButtons":0,"clientX":n.clientX,"clientY":n.clientY+this._vkTranslateYOffset,"pageX":n.pageX,"pageY":n.pageY+this._vkTranslateYOffset,"movementX":t.movementX||0,"movementY":t.movementY||0,"width":2*(n["radiusX"]||n["webkitRadiusX"]||0),"height":2*(n["radiusY"]||n["webkitRadiusY"]||0),"pressure":n["force"]||n["webkitForce"]||0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":n["rotationAngle"]||0,"timeStamp":t.timeStamp},s)}}_HandlePointerDownFocus(e){window!==window.top&&window.focus(),this._IsElementCanvasOrDocument(e.target)&&document.activeElement&&!this._IsElementCanvasOrDocument(document.activeElement)&&document.activeElement.blur()}_IsElementCanvasOrDocument(e){return!e||e===document||e===window||e===document.body||"canvas"===e.tagName.toLowerCase()}_AttachDeviceOrientationEvent(){this._attachedDeviceOrientationEvent||(this._attachedDeviceOrientationEvent=!0,window.addEventListener("deviceorientation",e=>this._OnDeviceOrientation(e)),window.addEventListener("deviceorientationabsolute",e=>this._OnDeviceOrientationAbsolute(e)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=!0,window.addEventListener("devicemotion",e=>this._OnDeviceMotion(e)))}_OnDeviceOrientation(e){this._isExportToVideo||this.PostToRuntime("deviceorientation",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp,"webkitCompassHeading":e["webkitCompassHeading"],"webkitCompassAccuracy":e["webkitCompassAccuracy"]},s)}_OnDeviceOrientationAbsolute(e){this._isExportToVideo||this.PostToRuntime("deviceorientationabsolute",{"absolute":!!e["absolute"],"alpha":e["alpha"]||0,"beta":e["beta"]||0,"gamma":e["gamma"]||0,"timeStamp":e.timeStamp},s)}_OnDeviceMotion(e){if(this._isExportToVideo)return;let t=null;const i=e["acceleration"];i&&(t={"x":i["x"]||0,"y":i["y"]||0,"z":i["z"]||0});let n=null;const o=e["accelerationIncludingGravity"];o&&(n={"x":o["x"]||0,"y":o["y"]||0,"z":o["z"]||0});let a=null;const d=e["rotationRate"];d&&(a={"alpha":d["alpha"]||0,"beta":d["beta"]||0,"gamma":d["gamma"]||0}),this.PostToRuntime("devicemotion",{"acceleration":t,"accelerationIncludingGravity":n,"rotationRate":a,"interval":e["interval"],"timeStamp":e.timeStamp},s)}_OnInvokeDownload(e){const t=e["url"],i=e["filename"],n=document.createElement("a"),s=document.body;n.textContent=i,n.href=t,n.download=i,s.appendChild(n),n.click(),s.removeChild(n)}async _OnLoadWebFonts(e){const t=e["webfonts"];await Promise.all(t.map(async e=>{const t=new FontFace(e.name,`url('${e.url}')`);document.fonts.add(t),await t.load()}))}async _OnRasterSvgImage(e){const t=e["blob"],i=e["imageWidth"],n=e["imageHeight"],s=e["surfaceWidth"],o=e["surfaceHeight"],a=e["imageBitmapOpts"],d=await self["C3_RasterSvgImageBlob"](t,i,n,s,o);let r;return r=a?await createImageBitmap(d,a):await createImageBitmap(d),{"imageBitmap":r,"transferables":[r]}}async _OnGetSvgImageSize(e){return await self["C3_GetSvgImageSize"](e["blob"])}async _OnAddStylesheet(e){var t;await(t=e["url"],new Promise((e,i)=>{const n=document.createElement("link");n.onload=()=>e(n),n.onerror=e=>i(e),n.rel="stylesheet",n.href=t,document.head.appendChild(n)}))}_PlayPendingMedia(){const e=[...this._mediaPendingPlay];if(this._mediaPendingPlay.clear(),!this._isSilent)for(const t of e){const e=t.play();e&&e.catch(e=>{this._mediaRemovedPendingPlay.has(t)||this._mediaPendingPlay.add(t)})}}TryPlayMedia(e){if("function"!=typeof e.play)throw new Error("missing play function");let t;this._mediaRemovedPendingPlay.delete(e);try{t=e.play()}catch(t){return void this._mediaPendingPlay.add(e)}t&&t.catch(t=>{this._mediaRemovedPendingPlay.has(e)||this._mediaPendingPlay.add(e)})}RemovePendingPlay(e){this._mediaPendingPlay.delete(e),this._mediaRemovedPendingPlay.add(e)}SetSilent(e){this._isSilent=!!e}_OnGamepadConnected(){this._isPollingGamepads||(this._iRuntime._AddRAFCallback(this._pollGamepadRafCallback),this._isPollingGamepads=!0,this._OnAnyGamepadInput())}_OnGamepadDisconnected(){this._isPollingGamepads&&navigator.getGamepads().every(e=>!e)&&(this._iRuntime._RemoveRAFCallback(this._pollGamepadRafCallback),this._isPollingGamepads=!1)}_OnPollGamepads(){navigator.getGamepads().some(e=>e&&e.buttons.some(e=>e.pressed))&&this._OnAnyGamepadInput()}_OnAnyGamepadInput(){this._PlayPendingMedia();for(const e of this._gamepadInputCallbacks)e()}_AddAnyGamepadInputCallback(e){this._gamepadInputCallbacks.add(e)}_RemoveAnyGamepadInputCallback(e){this._gamepadInputCallbacks.delete(e)}_OnHideCordovaSplash(){navigator["splashscreen"]&&navigator["splashscreen"]["hide"]&&navigator["splashscreen"]["hide"]()}_OnDebugHighlight(e){if(!e["show"])return void(this._debugHighlightElem&&(this._debugHighlightElem.style.display="none"));this._debugHighlightElem||(this._debugHighlightElem=document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));const t=this._debugHighlightElem;t.style.display="",t.style.left=e["left"]-1+"px",t.style.top=e["top"]-1+"px",t.style.width=e["width"]+2+"px",t.style.height=e["height"]+2+"px",t.textContent=e["name"]}_OnRegisterSW(){window["C3_RegisterSW"]&&window["C3_RegisterSW"]()}_OnPostToDebugger(e){window["c3_postToMessagePort"]&&(e["from"]="runtime",window["c3_postToMessagePort"](e))}_InvokeFunctionFromJS(e,t){return this.PostToRuntimeAsync("js-invoke-function",{"name":e,"params":t})}_OnScriptCreateWorker(e){const t=e["url"],i=e["opts"],n=e["port2"];new Worker(t,i).postMessage({"type":"construct-worker-init","port2":n},[n])}_OnAlert(e){alert(e["message"])}_OnScreenReaderTextEvent(e){const t=e["type"];if("create"===t){const t=document.createElement("p");t.id="c3-sr-"+e["id"],t.textContent=e["text"],this._screenReaderTextWrap.appendChild(t)}else if("update"===t){const t=document.getElementById("c3-sr-"+e["id"]);t?t.textContent=e["text"]:console.warn(`[Construct] Missing screen reader text with id ${e["id"]}`)}else if("release"===t){const t=document.getElementById("c3-sr-"+e["id"]);t?t.remove():console.warn(`[Construct] Missing screen reader text with id ${e["id"]}`)}else console.warn(`[Construct] Unknown screen reader text update '${t}'`)}_SetExportingToVideo(e){this._isExportToVideo=!0;const t=document.createElement("h1");t.id="exportToVideoMessage",t.textContent=e["message"],document.body.prepend(t),document.body.classList.add("exportingToVideo"),this.GetRuntimeInterface().GetMainCanvas().style.display="",this._iRuntime.SetIsExportingToVideo(e["duration"])}_OnExportVideoProgress(e){this._exportVideoProgressMessage=e["message"],-1===this._exportVideoUpdateTimerId&&(this._exportVideoUpdateTimerId=setTimeout(()=>this._DoUpdateExportVideoProgressMessage(),250))}_DoUpdateExportVideoProgressMessage(){this._exportVideoUpdateTimerId=-1;const e=document.getElementById("exportToVideoMessage");e&&(e.textContent=this._exportVideoProgressMessage)}_OnExportedToVideo(e){window.c3_postToMessagePort({"type":"exported-video","arrayBuffer":e["arrayBuffer"],"contentType":e["contentType"],"time":e["time"]})}_OnExportedToImageSequence(e){window.c3_postToMessagePort({"type":"exported-image-sequence","blobArr":e["blobArr"],"time":e["time"],"gif":e["gif"]})}};e.AddDOMHandlerClass(w)}

// workers/jobSchedulerDom.js
"use strict";{const t="dispatchworker.js",r="jobworker.js";self.JobSchedulerDOM=class{constructor(t){this._runtimeInterface=t,this._maxNumWorkers=Math.min(navigator.hardwareConcurrency||2,16),this._dispatchWorker=null,this._jobWorkers=[],this._inputPort=null,this._outputPort=null}async Init(){if(this._hasInitialised)throw new Error("already initialised");this._hasInitialised=!0;const r=this._runtimeInterface.GetScriptFolder()+t;this._dispatchWorker=await this._runtimeInterface.CreateWorker(r,{name:"DispatchWorker"});const e=new MessageChannel;this._inputPort=e.port1,this._dispatchWorker.postMessage({"type":"_init","in-port":e.port2},[e.port2]),this._outputPort=await this._CreateJobWorker()}async _CreateJobWorker(){const t=this._jobWorkers.length,e=this._runtimeInterface.GetScriptFolder()+r,o=await this._runtimeInterface.CreateWorker(e,{name:"JobWorker"+t}),s=new MessageChannel,i=new MessageChannel;return this._dispatchWorker.postMessage({"type":"_addJobWorker","port":s.port1},[s.port1]),o.postMessage({"type":"init","number":t,"dispatch-port":s.port2,"output-port":i.port2},[s.port2,i.port2]),this._jobWorkers.push(o),i.port1}GetPortData(){return{"inputPort":this._inputPort,"outputPort":this._outputPort,"maxNumWorkers":this._maxNumWorkers}}GetPortTransferables(){return[this._inputPort,this._outputPort]}}}

// scripts/plugins/Keyboard/dom/domSide.js
"use strict";{const r="keyboard",o=class extends self.DOMHandler{constructor(o){super(o,r),this._isKeyboardLockSupported=!(!navigator["keyboard"]||!navigator["keyboard"]["lock"]),this.AddRuntimeMessageHandlers([["init",()=>this._OnInit()],["lock-keyboard",r=>this._OnLockKeyboard(r)],["unlock-keyboard",()=>this._OnUnlockKeyboard()]])}_OnInit(){return{"isKeyboardLockSupported":this._isKeyboardLockSupported}}async _OnLockKeyboard(r){const o=r["keysArr"];try{return 0===o.length?await navigator["keyboard"]["lock"]():await navigator["keyboard"]["lock"](o),{"isOk":!0}}catch(r){return console.error("Error locking keyboard:",r),{"isOk":!1}}}_OnUnlockKeyboard(){try{navigator["keyboard"]["unlock"]()}catch(r){console.error("Error unlocking keyboard:",r)}}};self.RuntimeInterface.AddDOMHandlerClass(o)}

// scripts/plugins/Audio/dom/domSide.js
"use strict";{const t=180/Math.PI,e="audio";self.AudioDOMHandler=class extends self.DOMHandler{constructor(t){super(t,e),this._audioContext=null,this._destinationNode=null,this._hasAttachedUnblockEvents=!1,this._unblockFunc=()=>this._UnblockAudioContext(),this._audioBuffers=[],this._audioInstances=[],this._lastAudioInstance=null,this._lastPlayedTags=[],this._loadedAudioUrls=new Set,this._lastTickCount=-1,this._pendingTags=new Map,this._masterVolume=1,this._isSilent=!1,this._timeScaleMode=0,this._timeScale=1,this._gameTime=0,this._panningModel="HRTF",this._distanceModel="inverse",this._refDistance=600,this._maxDistance=1e4,this._rolloffFactor=1,this._lastListenerPos=[0,0,0],this._lastListenerOrientation=[0,0,-1,0,1,0],this._playMusicAsSound=!1,this._lastMusicBuffer=null,this._effects=new Map,this._analysers=new Set,this._isPendingPostFxState=!1,this._hasStartedOfflineRender=!1,this._microphoneTag="",this._microphoneSource=null,self["C3Audio_OnMicrophoneStream"]=(t,e)=>this._OnMicrophoneStream(t,e),this._destMediaStreamNode=null,self["C3Audio_GetOutputStream"]=()=>this._OnGetOutputStream(),self["C3Audio_DOMInterface"]=this,this.AddRuntimeMessageHandlers([["create-audio-context",t=>this._CreateAudioContext(t)],["play",t=>this._Play(t)],["stop",t=>this._Stop(t)],["stop-all",()=>this._StopAll()],["set-paused",t=>this._SetPaused(t)],["set-volume",t=>this._SetVolume(t)],["fade-volume",t=>this._FadeVolume(t)],["set-master-volume",t=>this._SetMasterVolume(t)],["set-muted",t=>this._SetMuted(t)],["set-silent",t=>this._SetSilent(t)],["set-looping",t=>this._SetLooping(t)],["set-playback-rate",t=>this._SetPlaybackRate(t)],["set-stereo-pan",t=>this._SetStereoPan(t)],["seek",t=>this._Seek(t)],["preload",t=>this._Preload(t)],["unload",t=>this._Unload(t)],["unload-all",()=>this._UnloadAll()],["set-suspended",t=>this._SetSuspended(t)],["add-effect",t=>this._AddEffect(t)],["set-effect-param",t=>this._SetEffectParam(t)],["remove-effects",t=>this._RemoveEffects(t)],["tick",t=>this._OnTick(t)],["load-state",t=>this._OnLoadState(t)],["offline-render-audio",t=>this._OnOfflineRenderAudio(t)],["offline-render-finish",()=>this._OnOfflineRenderFinish()]])}async _CreateAudioContext(t){if(t["usePlayMusicAsSoundWorkaround"]&&(this._playMusicAsSound=!0),this._timeScaleMode=t["timeScaleMode"],this._panningModel=["equalpower","HRTF","soundfield"][t["panningModel"]],this._distanceModel=["linear","inverse","exponential"][t["distanceModel"]],this._refDistance=t["refDistance"],this._maxDistance=t["maxDistance"],this._rolloffFactor=t["rolloffFactor"],this._iRuntime.IsExportingToVideo()){this._playMusicAsSound=!0;const t=48e3;this._audioContext=new OfflineAudioContext({"numberOfChannels":2,"sampleRate":t,"length":Math.ceil(this._iRuntime.GetExportToVideoDuration()*t)})}else this._audioContext=new AudioContext({"latencyHint":t["latencyHint"]}),"running"!==this._audioContext.state&&this._AttachUnblockEvents(),this._audioContext.onstatechange=()=>{"running"===this._audioContext.state?this._DetachUnblockEvents():this._AttachUnblockEvents(),this.PostToRuntime("audiocontext-state",{"audioContextState":this._audioContext.state})};this._destinationNode=this._audioContext["createGain"](),this._destinationNode["connect"](this._audioContext["destination"]);const e=t["listenerPos"];this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2]),this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation),self["C3_GetAudioContextCurrentTime"]=()=>this.GetAudioCurrentTime();try{await Promise.all(t["preloadList"].map(t=>this._GetAudioBuffer(t["originalUrl"],t["url"],t["type"],!1)))}catch(t){console.error("[Construct] Preloading sounds failed: ",t)}return{"sampleRate":this._audioContext["sampleRate"],"audioContextState":this._audioContext.state,"outputLatency":this._audioContext["outputLatency"]||0}}_AttachUnblockEvents(){this._hasAttachedUnblockEvents||(window.addEventListener("pointerup",this._unblockFunc,!0),window.addEventListener("touchend",this._unblockFunc,!0),window.addEventListener("click",this._unblockFunc,!0),window.addEventListener("keydown",this._unblockFunc,!0),this._iRuntime.AddAnyGamepadInputCallback(this._unblockFunc),this._iRuntime.IsiOSWebView()||document.addEventListener("visibilitychange",this._unblockFunc),this._hasAttachedUnblockEvents=!0)}_DetachUnblockEvents(){this._hasAttachedUnblockEvents&&(window.removeEventListener("pointerup",this._unblockFunc,!0),window.removeEventListener("touchend",this._unblockFunc,!0),window.removeEventListener("click",this._unblockFunc,!0),window.removeEventListener("keydown",this._unblockFunc,!0),this._iRuntime.RemoveAnyGamepadInputCallback(this._unblockFunc),this._iRuntime.IsiOSWebView()||document.removeEventListener("visibilitychange",this._unblockFunc),this._hasAttachedUnblockEvents=!1)}_UnblockAudioContext(){"running"!==this._audioContext["state"]&&this._audioContext["resume"]()}_MatchTagLists(t,e){for(const s of e){let e=!1;for(const i of t)if(self.AudioDOMHandler.EqualsNoCase(i,s)){e=!0;break}if(!e)return!1}return!0}GetAudioContext(){return this._audioContext}GetAudioCurrentTime(){return this._audioContext["currentTime"]}GetDestinationNode(){return this._destinationNode}"GetAudioContextExtern"(){return this.GetAudioContext()}"GetDestinationNodeExtern"(){return this.GetDestinationNode()}GetDestinationForTag(t){const e=this._effects.get(t.toLowerCase());return e?e[0].GetInputNode():this.GetDestinationNode()}AddEffectForTag(t,e){t=t.toLowerCase();let s=this._effects.get(t);s||(s=[],this._effects.set(t,s)),e._SetIndex(s.length),e._SetTag(t),s.push(e),this._ReconnectEffects(t)}_ReconnectEffects(t){t=t.toLowerCase();let e=this.GetDestinationNode();const s=this._effects.get(t);if(s&&s.length){e=s[0].GetInputNode();for(let t=0,e=s.length;t<e;++t){const i=s[t];t+1===e?i.ConnectTo(this.GetDestinationNode()):i.ConnectTo(s[t+1].GetInputNode())}}for(const s of this.audioInstancesByEffectTag(t))s.Reconnect(e);this._microphoneSource&&this._microphoneTag===t&&(this._microphoneSource["disconnect"](),this._microphoneSource["connect"](e))}GetMasterVolume(){return this._masterVolume}IsSilent(){return this._isSilent}GetTimeScaleMode(){return this._timeScaleMode}GetTimeScale(){return this._timeScale}GetGameTime(){return this._gameTime}IsPlayMusicAsSound(){return this._playMusicAsSound}GetPanningModel(){return this._panningModel}GetDistanceModel(){return this._distanceModel}GetReferenceDistance(){return this._refDistance}GetMaxDistance(){return this._maxDistance}GetRolloffFactor(){return this._rolloffFactor}TryPlayMedia(t){this._iRuntime.TryPlayMedia(t)}RemovePendingPlay(t){this._iRuntime.RemovePendingPlay(t)}ReleaseInstancesForBuffer(t){let e=0;for(let s=0,i=this._audioInstances.length;s<i;++s){const i=this._audioInstances[s];this._audioInstances[e]=i,i.GetBuffer()===t?i.Release():++e}this._audioInstances.length=e}ReleaseAllMusicBuffersExceptLast(){let t=0;for(let e=0,s=this._audioBuffers.length;e<s;++e){const s=this._audioBuffers[e];this._audioBuffers[t]=s,s.IsMusic()&&s!==this._lastMusicBuffer?s.Release():++t}this._audioBuffers.length=t}*audioInstancesMatchingTags(t){if(t.length>0)for(const e of this._audioInstances)this._MatchTagLists(e.GetTags(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}*audioInstancesByEffectTag(t){if(t)for(const e of this._audioInstances)self.AudioDOMHandler.EqualsNoCase(e.GetEffectTag(),t)&&(yield e);else this._lastAudioInstance&&!this._lastAudioInstance.HasEnded()&&(yield this._lastAudioInstance)}async _GetAudioBuffer(t,e,s,i,n){for(const t of this._audioBuffers)if(t.GetUrl()===e)return i&&this._playMusicAsSound&&(this._lastMusicBuffer=t),await t.Load(),t;if(n)return null;i&&this._playMusicAsSound&&this.ReleaseAllMusicBuffersExceptLast();const o=self.C3AudioBuffer.Create(this,t,e,s,i);return this._audioBuffers.push(o),i&&this._playMusicAsSound&&(this._lastMusicBuffer=o),await o.Load(),this._loadedAudioUrls.has(t)||(this.PostToRuntime("buffer-metadata",{"originalUrl":t,"duration":o.GetDuration()}),this._loadedAudioUrls.add(t)),o}async _GetAudioInstance(t,e,s,i,n){for(const t of this._audioInstances)if(t.GetUrl()===e&&(t.CanBeRecycled()||n))return n&&this._playMusicAsSound&&(this._lastMusicBuffer=t.GetBuffer()),t.SetTags(i),t;const o=await this._GetAudioBuffer(t,e,s,n);if(o.WasReleased())throw new Error(`buffer '${t}' unloaded while loading`);const a=o.CreateInstance(i);return this._audioInstances.push(a),a}_AddPendingTags(t){const e=t.join(" ");let s=this._pendingTags.get(e);if(!s){let t=null;s={pendingCount:0,promise:new Promise(e=>t=e),resolve:t},this._pendingTags.set(e,s)}s.pendingCount++}_RemovePendingTags(t){const e=t.join(" "),s=this._pendingTags.get(e);if(!s)throw new Error("expected pending tag");s.pendingCount--,0===s.pendingCount&&(s.resolve(),this._pendingTags.delete(e))}TagsReady(t){const e=(0===t.length?this._lastPlayedTags:t).join(" "),s=this._pendingTags.get(e);return s?s.promise:Promise.resolve()}_MaybeStartTicking(){if(this._analysers.size>0)this._StartTicking();else for(const t of this._audioInstances)if(t.IsActive())return void this._StartTicking()}Tick(){for(const t of this._analysers)t.Tick();const t=this.GetAudioCurrentTime();for(const e of this._audioInstances)e.Tick(t);const e=this._audioInstances.filter(t=>t.IsActive()).map(t=>t.GetState());this.PostToRuntime("state",{"tickCount":this._lastTickCount,"outputLatency":this._audioContext["outputLatency"]||0,"audioInstances":e,"analysers":[...this._analysers].map(t=>t.GetData())}),0===e.length&&0===this._analysers.size&&this._StopTicking()}PostTrigger(t,e,s){this.PostToRuntime("trigger",{"type":t,"tags":e,"aiid":s})}async _Play(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"],o=t["tags"],a=t["isLooping"],r=t["vol"],l=t["pos"],u=t["panning"],d=t["stereoPan"];let h=t["off"];h>0&&!t["trueClock"]&&(h+=this.GetAudioCurrentTime()),this._lastPlayedTags=o.slice(0),this._AddPendingTags(o);try{this._lastAudioInstance=await this._GetAudioInstance(e,s,i,o,n),u?(this._lastAudioInstance.SetPannerEnabled(!0),this._lastAudioInstance.SetPan(u["x"],u["y"],u["z"],u["angle"],u["innerAngle"],u["outerAngle"],u["outerGain"]),u.hasOwnProperty("uid")&&this._lastAudioInstance.SetUID(u["uid"])):"number"==typeof d&&0!==d?(this._lastAudioInstance.SetStereoPannerEnabled(!0),this._lastAudioInstance.SetStereoPan(d)):(this._lastAudioInstance.SetPannerEnabled(!1),this._lastAudioInstance.SetStereoPannerEnabled(!1)),this._lastAudioInstance.Play(a,r,l,h)}catch(t){return void console.error("[Construct] Audio: error starting playback: ",t)}finally{this._RemovePendingTags(o)}this._StartTicking()}_Stop(t){const e=t["tags"];for(const t of this.audioInstancesMatchingTags(e))t.Stop()}_StopAll(){for(const t of this._audioInstances)t.Stop()}_SetPaused(t){const e=t["tags"],s=t["paused"];for(const t of this.audioInstancesMatchingTags(e))s?t.Pause():t.Resume();this._MaybeStartTicking()}_SetVolume(t){const e=t["tags"],s=t["vol"];for(const t of this.audioInstancesMatchingTags(e))t.SetVolume(s)}_SetStereoPan(t){const e=t["tags"],s=t["p"];for(const t of this.audioInstancesMatchingTags(e))t.SetStereoPannerEnabled(!0),t.SetStereoPan(s)}async _FadeVolume(t){const e=t["tags"],s=t["vol"],i=t["duration"],n=t["stopOnEnd"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.FadeVolume(s,i,n);this._MaybeStartTicking()}_SetMasterVolume(t){this._masterVolume=t["vol"],this._destinationNode["gain"]["value"]=this._masterVolume}_SetMuted(t){const e=t["tags"],s=t["isMuted"];for(const t of this.audioInstancesMatchingTags(e))t.SetMuted(s)}_SetSilent(t){this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent);for(const t of this._audioInstances)t._UpdateMuted()}_SetLooping(t){const e=t["tags"],s=t["isLooping"];for(const t of this.audioInstancesMatchingTags(e))t.SetLooping(s)}async _SetPlaybackRate(t){const e=t["tags"],s=t["rate"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.SetPlaybackRate(s)}async _Seek(t){const e=t["tags"],s=t["pos"];await this.TagsReady(e);for(const t of this.audioInstancesMatchingTags(e))t.Seek(s)}async _Preload(t){const e=t["originalUrl"],s=t["url"],i=t["type"],n=t["isMusic"];try{await this._GetAudioInstance(e,s,i,"",n)}catch(t){console.error("[Construct] Audio: error preloading: ",t)}}async _Unload(t){const e=t["url"],s=t["type"],i=t["isMusic"],n=await this._GetAudioBuffer("",e,s,i,!0);if(!n)return;n.Release(),this._lastMusicBuffer===n&&(this._lastMusicBuffer=null);const o=this._audioBuffers.indexOf(n);-1!==o&&this._audioBuffers.splice(o,1)}_UnloadAll(){for(const t of this._audioBuffers)t.Release(),this._lastMusicBuffer===t&&(this._lastMusicBuffer=null);this._audioBuffers.length=0}_SetSuspended(t){const e=t["isSuspended"];!e&&this._audioContext["resume"]&&this._audioContext["resume"]();for(const t of this._audioInstances)t.SetSuspended(e);e&&this._audioContext["suspend"]&&this._audioContext["suspend"]()}_OnTick(t){if(this._timeScale=t["timeScale"],this._gameTime=t["gameTime"],this._lastTickCount=t["tickCount"],0!==this._timeScaleMode)for(const t of this._audioInstances)t._UpdatePlaybackRate();const e=t["listenerPos"];!e||this._lastListenerPos[0]===e[0]&&this._lastListenerPos[1]===e[1]&&this._lastListenerPos[2]===e[2]||(this._lastListenerPos[0]=e[0],this._lastListenerPos[1]=e[1],this._lastListenerPos[2]=e[2],this._audioContext["listener"]["setPosition"](e[0],e[1],e[2]));const s=t["listenerOrientation"];if(s&&(this._lastListenerOrientation[0]!==s[0]||this._lastListenerOrientation[1]!==s[1]||this._lastListenerOrientation[2]!==s[2]||this._lastListenerOrientation[3]!==s[3]||this._lastListenerOrientation[4]!==s[4]||this._lastListenerOrientation[5]!==s[5])){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=s[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}for(const e of t["instPans"]){const t=e["uid"];for(const s of this._audioInstances)s.GetUID()===t&&s.SetPanXYZA(e["x"],e["y"],e["z"],e["angle"])}}async _AddEffect(t){const e=t["type"],s=t.hasOwnProperty("tags")?t["tags"]:[t["tag"]],i=t["params"];let n,o;if("convolution"===e)try{o=await this._GetAudioBuffer(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"],!1)}catch(t){return void console.log("[Construct] Audio: error loading convolution: ",t)}for(const a of s){if("filter"===e)n=new self.C3AudioFilterFX(this,...i);else if("delay"===e)n=new self.C3AudioDelayFX(this,...i);else if("convolution"===e)n=new self.C3AudioConvolveFX(this,o.GetAudioBuffer(),...i),n._SetBufferInfo(t["bufferOriginalUrl"],t["bufferUrl"],t["bufferType"]);else if("flanger"===e)n=new self.C3AudioFlangerFX(this,...i);else if("phaser"===e)n=new self.C3AudioPhaserFX(this,...i);else if("gain"===e)n=new self.C3AudioGainFX(this,...i);else if("stereopan"===e)n=new self.C3AudioStereoPanFX(this,...i);else if("tremolo"===e)n=new self.C3AudioTremoloFX(this,...i);else if("ringmod"===e)n=new self.C3AudioRingModFX(this,...i);else if("distortion"===e)n=new self.C3AudioDistortionFX(this,...i);else if("compressor"===e)n=new self.C3AudioCompressorFX(this,...i);else{if("analyser"!==e)throw new Error("invalid effect type");n=new self.C3AudioAnalyserFX(this,...i)}this.AddEffectForTag(a,n)}this._PostUpdatedFxState()}_SetEffectParam(t){const e=t["tags"],s=t["index"],i=t["param"],n=t["value"],o=t["ramp"],a=t["time"];for(const t of e){const e=this._effects.get(t.toLowerCase());!e||s<0||s>=e.length||e[s].SetParam(i,n,o,a)}this._PostUpdatedFxState()}_RemoveEffects(t){const e=t["tags"];for(const t of e){const e=t.toLowerCase(),s=this._effects.get(e);if(!s||!s.length)return;for(const t of s)t.Release();this._effects.delete(e),this._ReconnectEffects(e)}}_AddAnalyser(t){this._analysers.add(t),this._MaybeStartTicking()}_RemoveAnalyser(t){this._analysers.delete(t)}_PostUpdatedFxState(){this._isPendingPostFxState||(this._isPendingPostFxState=!0,Promise.resolve().then(()=>this._DoPostUpdatedFxState()))}_DoPostUpdatedFxState(){const t={};for(const[e,s]of this._effects)t[e]=s.map(t=>t.GetState());this.PostToRuntime("fxstate",{"fxstate":t}),this._isPendingPostFxState=!1}async _OnLoadState(t){const e=t["saveLoadMode"];if(3!==e){const t=[];for(const s of this._audioInstances)s.IsMusic()&&1===e||!s.IsMusic()&&2===e?t.push(s):s.Release();this._audioInstances=t}for(const t of this._effects.values())for(const e of t)e.Release();this._effects.clear(),this._timeScale=t["timeScale"],this._gameTime=t["gameTime"];const s=t["listenerPos"];this._lastListenerPos[0]=s[0],this._lastListenerPos[1]=s[1],this._lastListenerPos[2]=s[2],this._audioContext["listener"]["setPosition"](s[0],s[1],s[2]);const i=t["listenerOrientation"];if(Array.isArray(i)){for(let t=0;t<6;++t)this._lastListenerOrientation[t]=i[t];this._audioContext["listener"]["setOrientation"](...this._lastListenerOrientation)}this._isSilent=t["isSilent"],this._iRuntime.SetSilent(this._isSilent),this._masterVolume=t["masterVolume"],this._destinationNode["gain"]["value"]=this._masterVolume;const n=[];for(const e of Object.values(t["effects"]))n.push(Promise.all(e.map(t=>this._AddEffect(t))));await Promise.all(n),await Promise.all(t["playing"].map(t=>this._LoadAudioInstance(t,e))),this._MaybeStartTicking()}async _LoadAudioInstance(t,e){if(3===e)return;const s=t["bufferOriginalUrl"],i=t["bufferUrl"],n=t["bufferType"],o=t["isMusic"],a=t["tags"],r=t["isLooping"],l=t["volume"],u=t["playbackTime"];if(o&&1===e)return;if(!o&&2===e)return;let d=null;try{d=await this._GetAudioInstance(s,i,n,a,o)}catch(t){return void console.error("[Construct] Audio: error loading audio state: ",t)}d.LoadPanState(t["pan"]),d.LoadStereoPanState(t["stereoPan"]),d.Play(r,l,u,0),t["isPlaying"]||d.Pause(),d._LoadAdditionalState(t)}_OnMicrophoneStream(t,e){this._microphoneSource&&this._microphoneSource["disconnect"](),this._microphoneTag=e.toLowerCase(),this._microphoneSource=this._audioContext["createMediaStreamSource"](t),this._microphoneSource["connect"](this.GetDestinationForTag(this._microphoneTag))}_OnGetOutputStream(){return this._destMediaStreamNode||(this._destMediaStreamNode=this._audioContext["createMediaStreamDestination"](),this._destinationNode["connect"](this._destMediaStreamNode)),this._destMediaStreamNode["stream"]}async _OnOfflineRenderAudio(t){try{const e=t["time"],s=this._audioContext["suspend"](e);this._hasStartedOfflineRender?this._audioContext["resume"]():(this._audioContext["startRendering"]().then(t=>this._OnOfflineRenderCompleted(t)).catch(t=>this._OnOfflineRenderError(t)),this._hasStartedOfflineRender=!0),await s}catch(t){this._OnOfflineRenderError(t)}}_OnOfflineRenderFinish(){this._audioContext["resume"]()}_OnOfflineRenderCompleted(t){const e=[];for(let s=0,i=t["numberOfChannels"];s<i;++s){const i=t["getChannelData"](s);e.push(i.buffer)}this._iRuntime.PostToRuntimeComponent("runtime","offline-audio-render-completed",{"duration":t["duration"],"length":t["length"],"numberOfChannels":t["numberOfChannels"],"sampleRate":t["sampleRate"],"channelData":e},null,e)}_OnOfflineRenderError(t){console.error("[Audio] Offline rendering error: ",t)}static EqualsNoCase(t,e){return t===e||t.normalize().toLowerCase()===e.normalize().toLowerCase()}static ToDegrees(e){return e*t}static DbToLinearNoCap(t){return Math.pow(10,t/20)}static DbToLinear(t){return Math.max(Math.min(self.AudioDOMHandler.DbToLinearNoCap(t),1),0)}static LinearToDbNoCap(t){return Math.log(t)/Math.log(10)*20}static LinearToDb(t){return self.AudioDOMHandler.LinearToDbNoCap(Math.max(Math.min(t,1),0))}static e4(t,e){return 1-Math.exp(-e*t)}},self.RuntimeInterface.AddDOMHandlerClass(self.AudioDOMHandler)}

// scripts/plugins/Audio/dom/audioBuffer.js
"use strict";self.C3AudioBuffer=class{constructor(t,e,i,s,o){this._audioDomHandler=t,this._originalUrl=e,this._url=i,this._type=s,this._isMusic=o,this._api="",this._loadState="not-loaded",this._loadPromise=null}Release(){this._loadState="not-loaded",this._audioDomHandler=null,this._loadPromise=null}WasReleased(){return!this._audioDomHandler}static Create(t,e,i,s,o){return!o||t.IsPlayMusicAsSound()?new self.C3WebAudioBuffer(t,e,i,s,o):new self.C3Html5AudioBuffer(t,e,i,s,o)}CreateInstance(t){return"html5"===this._api?new self.C3Html5AudioInstance(this._audioDomHandler,this,t):new self.C3WebAudioInstance(this._audioDomHandler,this,t)}_Load(){}Load(){return this._loadPromise||(this._loadPromise=this._Load()),this._loadPromise}IsLoaded(){}IsLoadedAndDecoded(){}HasFailedToLoad(){return"failed"===this._loadState}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}GetApi(){return this._api}GetOriginalUrl(){return this._originalUrl}GetUrl(){return this._url}GetContentType(){return this._type}IsMusic(){return this._isMusic}GetDuration(){}};

// scripts/plugins/Audio/dom/html5AudioBuffer.js
"use strict";self.C3Html5AudioBuffer=class extends self.C3AudioBuffer{constructor(e,t,o,i,d){super(e,t,o,i,d),this._api="html5",this._audioElem=new Audio,this._audioElem.crossOrigin="anonymous",this._audioElem.autoplay=!1,this._audioElem.preload="auto",this._loadResolve=null,this._loadReject=null,this._reachedCanPlayThrough=!1,this._audioElem.addEventListener("canplaythrough",()=>this._reachedCanPlayThrough=!0),this._outNode=this.GetAudioContext()["createGain"](),this._mediaSourceNode=null,this._audioElem.addEventListener("canplay",()=>{this._loadResolve&&(this._loadState="loaded",this._loadResolve(),this._loadResolve=null,this._loadReject=null),!this._mediaSourceNode&&this._audioElem&&(this._mediaSourceNode=this.GetAudioContext()["createMediaElementSource"](this._audioElem),this._mediaSourceNode["connect"](this._outNode))}),this.onended=null,this._audioElem.addEventListener("ended",()=>{this.onended&&this.onended()}),this._audioElem.addEventListener("error",e=>this._OnError(e))}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this),this._outNode["disconnect"](),this._outNode=null,this._mediaSourceNode["disconnect"](),this._mediaSourceNode=null,this._audioElem&&!this._audioElem.paused&&this._audioElem.pause(),this.onended=null,this._audioElem=null,super.Release()}_Load(){return this._loadState="loading",new Promise((e,t)=>{this._loadResolve=e,this._loadReject=t,this._audioElem.src=this._url})}_OnError(e){console.error(`[Construct] Audio '${this._url}' error: `,e),this._loadReject&&(this._loadState="failed",this._loadReject(e),this._loadResolve=null,this._loadReject=null)}IsLoaded(){const e=this._audioElem["readyState"]>=4;return e&&(this._reachedCanPlayThrough=!0),e||this._reachedCanPlayThrough}IsLoadedAndDecoded(){return this.IsLoaded()}GetAudioElement(){return this._audioElem}GetOutputNode(){return this._outNode}GetDuration(){return this._audioElem["duration"]}};

// scripts/plugins/Audio/dom/webAudioBuffer.js
"use strict";self.C3WebAudioBuffer=class extends self.C3AudioBuffer{constructor(a,t,e,i,u){super(a,t,e,i,u),this._api="webaudio",this._audioData=null,this._audioBuffer=null}Release(){this._audioDomHandler.ReleaseInstancesForBuffer(this),this._audioData=null,this._audioBuffer=null,super.Release()}async _Fetch(){if(this._audioData)return this._audioData;const a=this._audioDomHandler.GetRuntimeInterface();if("playable-ad-single-file"===a.GetExportType()&&a.IsRelativeURL(this._url)){const t=a["_PlayableAdFetchBlob"](this._url);this._audioData=await t.arrayBuffer()}else{const a=await fetch(this._url);if(!a.ok)throw new Error(`error fetching audio data: ${a.status} ${a.statusText}`);this._audioData=await a.arrayBuffer()}}async _Decode(){if(this._audioBuffer)return this._audioBuffer;const a=this._audioDomHandler.GetAudioContext();this._audioBuffer=await a["decodeAudioData"](this._audioData),this._audioData=null}async _Load(){try{if(this._loadState="loading",await this._Fetch(),this.WasReleased())return;await this._Decode(),this._loadState="loaded"}catch(a){this._loadState="failed",console.error(`[Construct] Failed to load audio '${this._url}': `,a)}}IsLoaded(){return!(!this._audioData&&!this._audioBuffer)}IsLoadedAndDecoded(){return!!this._audioBuffer}GetAudioBuffer(){return this._audioBuffer}GetDuration(){return this._audioBuffer?this._audioBuffer["duration"]:0}};

// scripts/plugins/Audio/dom/audioInstance.js
"use strict";{let e=0;self.C3AudioInstance=class{constructor(t,n,i){this._audioDomHandler=t,this._buffer=n,this._tags=i,this._lastEffectTag=this.GetEffectTag(),this._aiId=e++,this._gainNode=this.GetAudioContext()["createGain"](),this._gainNode["connect"](this.GetDestinationNode()),this._pannerNode=null,this._isPannerEnabled=!1,this._pannerPosition=[0,0,0],this._pannerOrientation=[0,0,0],this._pannerConeParams=[0,0,0],this._stereoPannerNode=null,this._isStereoPannerEnabled=!1,this._stereoPan=0,this._isStopped=!0,this._isPaused=!1,this._resumeMe=!1,this._isLooping=!1,this._volume=1,this._isMuted=!1,this._playbackRate=1;const s=this._audioDomHandler.GetTimeScaleMode();this._isTimescaled=1===s&&!this.IsMusic()||2===s,this._instUid=-1,this._fadeEndTime=-1,this._stopOnFadeEnd=!1}Release(){this._audioDomHandler=null,this._buffer=null,this._pannerNode&&(this._pannerNode["disconnect"](),this._pannerNode=null),this._stereoPannerNode&&(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null),this._gainNode["disconnect"](),this._gainNode=null}GetAudioContext(){return this._audioDomHandler.GetAudioContext()}SetTags(e){this._tags=e;const t=this.GetEffectTag();this._lastEffectTag!==t&&(this._lastEffectTag=t,this.Reconnect(this.GetDestinationNode()))}GetTags(){return this._tags}GetEffectTag(){return this._tags.length>0?this._tags[0]:""}GetDestinationNode(){return this._audioDomHandler.GetDestinationForTag(this.GetEffectTag())}GetCurrentTime(){return this._isTimescaled?this._audioDomHandler.GetGameTime():performance.now()/1e3}GetOriginalUrl(){return this._buffer.GetOriginalUrl()}GetUrl(){return this._buffer.GetUrl()}GetContentType(){return this._buffer.GetContentType()}GetBuffer(){return this._buffer}IsMusic(){return this._buffer.IsMusic()}GetAiId(){return this._aiId}HasEnded(){}CanBeRecycled(){}IsPlaying(){return!this._isStopped&&!this._isPaused&&!this.HasEnded()}IsActive(){return!this._isStopped&&!this.HasEnded()}GetPlaybackTime(){}GetDuration(e){let t=this._buffer.GetDuration();return e&&(t/=this._playbackRate||.001),t}Play(e,t,n,i){}Stop(){}Pause(){}IsPaused(){return this._isPaused}Resume(){}SetVolume(e){this._volume=e,this._gainNode["gain"]["cancelScheduledValues"](0),this._fadeEndTime=-1,this._gainNode["gain"]["value"]=this.GetOutputVolume()}FadeVolume(e,t,n){if(this.IsMuted())return;const i=this._gainNode["gain"];i["cancelScheduledValues"](0);const s=this._audioDomHandler.GetAudioCurrentTime(),a=s+t;i["setValueAtTime"](i["value"],s),i["linearRampToValueAtTime"](e,a),this._volume=e,this._fadeEndTime=a,this._stopOnFadeEnd=n}_UpdateVolume(){this.SetVolume(this._volume)}Tick(e){-1!==this._fadeEndTime&&e>=this._fadeEndTime&&(this._fadeEndTime=-1,this._stopOnFadeEnd&&this.Stop(),this._audioDomHandler.PostTrigger("fade-ended",this._tags,this._aiId))}GetOutputVolume(){const e=this._volume;return isFinite(e)?e:0}SetMuted(e){e=!!e,this._isMuted!==e&&(this._isMuted=e,this._UpdateMuted())}IsMuted(){return this._isMuted}IsSilent(){return this._audioDomHandler.IsSilent()}_UpdateMuted(){}SetLooping(e){}IsLooping(){return this._isLooping}SetPlaybackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this._UpdatePlaybackRate())}_UpdatePlaybackRate(){}GetPlaybackRate(){return this._playbackRate}Seek(e){}SetSuspended(e){}SetPannerEnabled(e){e=!!e,this._isPannerEnabled!==e&&(this._isPannerEnabled=e,this._isPannerEnabled?(this.SetStereoPannerEnabled(!1),this._pannerNode||(this._pannerNode=this.GetAudioContext()["createPanner"](),this._pannerNode["panningModel"]=this._audioDomHandler.GetPanningModel(),this._pannerNode["distanceModel"]=this._audioDomHandler.GetDistanceModel(),this._pannerNode["refDistance"]=this._audioDomHandler.GetReferenceDistance(),this._pannerNode["maxDistance"]=this._audioDomHandler.GetMaxDistance(),this._pannerNode["rolloffFactor"]=this._audioDomHandler.GetRolloffFactor()),this._gainNode["disconnect"](),this._gainNode["connect"](this._pannerNode),this._pannerNode["connect"](this.GetDestinationNode())):(this._pannerNode["disconnect"](),this._gainNode["disconnect"](),this._gainNode["connect"](this.GetDestinationNode())))}SetPan(e,t,n,i,s,a,o){if(!this._isPannerEnabled)return;this.SetPanXYZA(e,t,n,i);const r=self.AudioDOMHandler.ToDegrees;this._pannerConeParams[0]!==r(s)&&(this._pannerConeParams[0]=r(s),this._pannerNode["coneInnerAngle"]=r(s)),this._pannerConeParams[1]!==r(a)&&(this._pannerConeParams[1]=r(a),this._pannerNode["coneOuterAngle"]=r(a)),this._pannerConeParams[2]!==o&&(this._pannerConeParams[2]=o,this._pannerNode["coneOuterGain"]=o)}SetPanXYZA(e,t,n,i){if(!this._isPannerEnabled)return;const s=this._pannerPosition,a=this._pannerOrientation,o=Math.cos(i),r=Math.sin(i);s[0]===e&&s[1]===t&&s[2]===n||(s[0]=e,s[1]=t,s[2]=n,this._pannerNode["setPosition"](...s)),a[0]===o&&a[1]===r&&0===a[2]||(a[0]=o,a[1]=r,a[2]=0,this._pannerNode["setOrientation"](...a))}SetStereoPannerEnabled(e){e=!!e,this._isStereoPannerEnabled!==e&&(this._isStereoPannerEnabled=e,this._isStereoPannerEnabled?(this.SetPannerEnabled(!1),this._stereoPannerNode=this.GetAudioContext()["createStereoPanner"](),this._gainNode["disconnect"](),this._gainNode["connect"](this._stereoPannerNode),this._stereoPannerNode["connect"](this.GetDestinationNode())):(this._stereoPannerNode["disconnect"](),this._stereoPannerNode=null,this._gainNode["disconnect"](),this._gainNode["connect"](this.GetDestinationNode())))}SetStereoPan(e){this._isStereoPannerEnabled&&this._stereoPan!==e&&(this._stereoPannerNode["pan"]["value"]=e,this._stereoPan=e)}SetUID(e){this._instUid=e}GetUID(){return this._instUid}GetResumePosition(){}Reconnect(e){const t=this._stereoPannerNode||this._pannerNode||this._gainNode;t["disconnect"](),t["connect"](e)}GetState(){return{"aiid":this.GetAiId(),"tags":this._tags,"duration":this.GetDuration(),"volume":-1===this._fadeEndTime?this._volume:this._gainNode["gain"]["value"],"isPlaying":this.IsPlaying(),"playbackTime":this.GetPlaybackTime(),"playbackRate":this.GetPlaybackRate(),"uid":this._instUid,"bufferOriginalUrl":this.GetOriginalUrl(),"bufferUrl":"","bufferType":this.GetContentType(),"isMusic":this.IsMusic(),"isLooping":this.IsLooping(),"isMuted":this.IsMuted(),"resumePosition":this.GetResumePosition(),"pan":this.GetPanState(),"stereoPan":this.GetStereoPanState()}}_LoadAdditionalState(e){this.SetPlaybackRate(e["playbackRate"]),this.SetMuted(e["isMuted"])}GetPanState(){if(!this._pannerNode)return null;const e=this._pannerNode;return{"pos":this._pannerPosition,"orient":this._pannerOrientation,"cia":e["coneInnerAngle"],"coa":e["coneOuterAngle"],"cog":e["coneOuterGain"],"uid":this._instUid}}LoadPanState(e){if(!e)return void this.SetPannerEnabled(!1);this.SetPannerEnabled(!0);const t=this._pannerNode,n=e["pos"];this._pannerPosition[0]=n[0],this._pannerPosition[1]=n[1],this._pannerPosition[2]=n[2];const i=e["orient"];this._pannerOrientation[0]=i[0],this._pannerOrientation[1]=i[1],this._pannerOrientation[2]=i[2],t["setPosition"](...this._pannerPosition),t["setOrientation"](...this._pannerOrientation),this._pannerConeParams[0]=e["cia"],this._pannerConeParams[1]=e["coa"],this._pannerConeParams[2]=e["cog"],t["coneInnerAngle"]=e["cia"],t["coneOuterAngle"]=e["coa"],t["coneOuterGain"]=e["cog"],this._instUid=e["uid"]}GetStereoPanState(){return this._stereoPannerNode?this._stereoPan:null}LoadStereoPanState(e){"number"==typeof e?(this.SetStereoPannerEnabled(!0),this.SetStereoPan(e)):this.SetStereoPannerEnabled(!1)}}}

// scripts/plugins/Audio/dom/html5AudioInstance.js
"use strict";self.C3Html5AudioInstance=class extends self.C3AudioInstance{constructor(e,t,i){super(e,t,i),this._buffer.GetOutputNode()["connect"](this._gainNode),this._buffer.onended=()=>this._OnEnded()}Release(){this.Stop(),this._buffer.GetOutputNode()["disconnect"](),super.Release()}GetAudioElement(){return this._buffer.GetAudioElement()}_OnEnded(){this._isStopped=!0,this._instUid=-1,this._audioDomHandler.PostTrigger("ended",this._tags,this._aiId)}HasEnded(){return this.GetAudioElement()["ended"]}CanBeRecycled(){return!!this._isStopped||this.HasEnded()}GetPlaybackTime(){let e=this.GetAudioElement()["currentTime"];return this._isLooping||(e=Math.min(e,this.GetDuration())),e}Play(e,t,i,s){const d=this.GetAudioElement();if(1!==d.playbackRate&&(d.playbackRate=1),d.loop!==e&&(d.loop=e),this.SetVolume(t),this._isMuted=!1,d.muted&&(d.muted=!1),d.currentTime!==i)try{d.currentTime=i}catch(e){console.warn(`[Construct] Exception seeking audio '${this._buffer.GetUrl()}' to position '${i}': `,e)}this._audioDomHandler.TryPlayMedia(d),this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1}Stop(){const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){if(this._isPaused||this._isStopped||this.HasEnded())return;const e=this.GetAudioElement();e.paused||e.pause(),this._audioDomHandler.RemovePendingPlay(e),this._isPaused=!0}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._isPaused=!1)}_UpdateMuted(){this.GetAudioElement().muted=this._isMuted||this.IsSilent()}SetLooping(e){e=!!e,this._isLooping!==e&&(this._isLooping=e,this.GetAudioElement().loop=e)}_UpdatePlaybackRate(){let e=this._playbackRate;this._isTimescaled&&(e*=this._audioDomHandler.GetTimeScale());try{this.GetAudioElement()["playbackRate"]=e}catch(t){console.warn(`[Construct] Unable to set playback rate '${e}':`,t)}}Seek(e){if(!this._isStopped&&!this.HasEnded())try{this.GetAudioElement()["currentTime"]=e}catch(t){console.warn(`[Construct] Error seeking audio to '${e}': `,t)}}GetResumePosition(){return this.GetPlaybackTime()}SetSuspended(e){e?this.IsPlaying()?(this.GetAudioElement()["pause"](),this._resumeMe=!0):this._resumeMe=!1:this._resumeMe&&(this._audioDomHandler.TryPlayMedia(this.GetAudioElement()),this._resumeMe=!1)}};

// scripts/plugins/Audio/dom/webAudioInstance.js
"use strict";self.C3WebAudioInstance=class extends self.C3AudioInstance{constructor(e,t,s){super(e,t,s),this._bufferSource=null,this._onended_handler=e=>this._OnEnded(e),this._hasPlaybackEnded=!0,this._activeSource=null,this._playStartTime=0,this._playFromSeekPos=0,this._resumePosition=0,this._muteVol=1}Release(){this.Stop(),this._ReleaseBufferSource(),this._onended_handler=null,super.Release()}_ReleaseBufferSource(){this._bufferSource&&(this._bufferSource["onended"]=null,this._bufferSource["disconnect"](),this._bufferSource["buffer"]=null),this._bufferSource=null,this._activeSource=null}_OnEnded(e){this._isPaused||this._resumeMe||e.target===this._activeSource&&(this._hasPlaybackEnded=!0,this._isStopped=!0,this._instUid=-1,this._ReleaseBufferSource(),this._audioDomHandler.PostTrigger("ended",this._tags,this._aiId))}HasEnded(){return!(!this._isStopped&&this._bufferSource&&this._bufferSource["loop"])&&(!this._isPaused&&this._hasPlaybackEnded)}CanBeRecycled(){return!(this._bufferSource&&!this._isStopped)||this.HasEnded()}GetPlaybackTime(){let e=0;return e=this._isPaused?this._resumePosition:this._playFromSeekPos+(this.GetCurrentTime()-this._playStartTime)*this._playbackRate,this._isLooping||(e=Math.min(e,this.GetDuration())),e}Play(e,t,s,i){this._isMuted=!1,this._muteVol=1,this.SetVolume(t),this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=e,this._bufferSource["start"](i,s),this._hasPlaybackEnded=!1,this._isStopped=!1,this._isPaused=!1,this._isLooping=e,this._playbackRate=1,this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=s}Stop(){if(this._bufferSource)try{this._bufferSource["stop"](0)}catch(e){}this._isStopped=!0,this._isPaused=!1,this._instUid=-1}Pause(){this._isPaused||this._isStopped||this.HasEnded()||(this._resumePosition=this.GetPlaybackTime(),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._isPaused=!0,this._bufferSource["stop"](0))}Resume(){!this._isPaused||this._isStopped||this.HasEnded()||(this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._isPaused=!1)}GetOutputVolume(){return super.GetOutputVolume()*this._muteVol}_UpdateMuted(){this._muteVol=this._isMuted||this.IsSilent()?0:1,this._UpdateVolume()}SetLooping(e){e=!!e,this._isLooping!==e&&(this._isLooping=e,this._bufferSource&&(this._bufferSource["loop"]=e))}_UpdatePlaybackRate(){let e=this._playbackRate;this._isTimescaled&&(e*=this._audioDomHandler.GetTimeScale()),this._bufferSource&&(this._bufferSource["playbackRate"]["value"]=e)}Seek(e){this._isStopped||this.HasEnded()||(this._isPaused?this._resumePosition=e:(this.Pause(),this._resumePosition=e,this.Resume()))}GetResumePosition(){return this._resumePosition}SetSuspended(e){e?this.IsPlaying()?(this._resumeMe=!0,this._resumePosition=this.GetPlaybackTime(),this._isLooping&&(this._resumePosition%=this.GetDuration()),this._bufferSource["stop"](0)):this._resumeMe=!1:this._resumeMe&&(this._ReleaseBufferSource(),this._bufferSource=this.GetAudioContext()["createBufferSource"](),this._bufferSource["buffer"]=this._buffer.GetAudioBuffer(),this._bufferSource["connect"](this._gainNode),this._activeSource=this._bufferSource,this._bufferSource["onended"]=this._onended_handler,this._bufferSource["loop"]=this._isLooping,this._UpdateVolume(),this._UpdatePlaybackRate(),this._bufferSource["start"](0,this._resumePosition),this._playStartTime=this.GetCurrentTime(),this._playFromSeekPos=this._resumePosition,this._resumeMe=!1)}_LoadAdditionalState(e){super._LoadAdditionalState(e),this._resumePosition=e["resumePosition"]}};

// scripts/plugins/Audio/dom/effects.js
"use strict";{class e{constructor(e){this._audioDomHandler=e,this._audioContext=e.GetAudioContext(),this._index=-1,this._tag="",this._type="",this._params=null}Release(){this._audioContext=null}_SetIndex(e){this._index=e}GetIndex(){return this._index}_SetTag(e){this._tag=e}GetTag(){return this._tag}CreateGain(){return this._audioContext["createGain"]()}GetInputNode(){}ConnectTo(e){}SetAudioParam(e,t,i,s){if(e["cancelScheduledValues"](0),0===s)return void(e["value"]=t);const o=this._audioContext["currentTime"];switch(s+=o,i){case 0:e["setValueAtTime"](t,s);break;case 1:e["setValueAtTime"](e["value"],o),e["linearRampToValueAtTime"](t,s);break;case 2:e["setValueAtTime"](e["value"],o),e["exponentialRampToValueAtTime"](t,s)}}GetState(){return{"type":this._type,"tag":this._tag,"params":this._params}}}self.C3AudioFilterFX=class extends e{constructor(e,t,i,s,o,a,n){super(e),this._type="filter",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]=t,this._filterNode["frequency"]["value"]=i,this._filterNode["detune"]["value"]=s,this._filterNode["Q"]["value"]=o,this._filterNode["gain"]["vlaue"]=a,this._inputNode["connect"](this._filterNode),this._inputNode["connect"](this._dryNode),this._filterNode["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._filterNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 1:this._params[1]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[2]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[3]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 4:this._params[4]=t,this.SetAudioParam(this._filterNode["gain"],t,i,s)}}},self.C3AudioDelayFX=class extends e{constructor(e,t,i,s){super(e),this._type="delay",this._params=[t,i,s],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._mainNode=this.CreateGain(),this._delayNode=this._audioContext["createDelay"](t),this._delayNode["delayTime"]["value"]=t,this._delayGainNode=this.CreateGain(),this._delayGainNode["gain"]["value"]=i,this._inputNode["connect"](this._mainNode),this._inputNode["connect"](this._dryNode),this._mainNode["connect"](this._wetNode),this._mainNode["connect"](this._delayNode),this._delayNode["connect"](this._delayGainNode),this._delayGainNode["connect"](this._mainNode)}Release(){this._inputNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),this._mainNode["disconnect"](),this._delayNode["disconnect"](),this._delayGainNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[2]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 4:this._params[1]=o(t),this.SetAudioParam(this._delayGainNode["gain"],o(t),i,s);break;case 5:this._params[0]=t,this.SetAudioParam(this._delayNode["delayTime"],t,i,s)}}},self.C3AudioConvolveFX=class extends e{constructor(e,t,i,s){super(e),this._type="convolution",this._params=[i,s],this._bufferOriginalUrl="",this._bufferUrl="",this._bufferType="",this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=s,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-s,this._convolveNode=this._audioContext["createConvolver"](),this._convolveNode["normalize"]=i,this._convolveNode["buffer"]=t,this._inputNode["connect"](this._convolveNode),this._inputNode["connect"](this._dryNode),this._convolveNode["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._convolveNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){if(0===e)t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s)}_SetBufferInfo(e,t,i){this._bufferOriginalUrl=e,this._bufferUrl=t,this._bufferType=i}GetState(){const e=super.GetState();return e["bufferOriginalUrl"]=this._bufferOriginalUrl,e["bufferUrl"]="",e["bufferType"]=this._bufferType,e}},self.C3AudioFlangerFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="flanger",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a/2,this._feedbackNode=this.CreateGain(),this._feedbackNode["gain"]["value"]=o,this._delayNode=this._audioContext["createDelay"](t+i),this._delayNode["delayTime"]["value"]=t,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=s,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i,this._inputNode["connect"](this._delayNode),this._inputNode["connect"](this._dryNode),this._delayNode["connect"](this._wetNode),this._delayNode["connect"](this._feedbackNode),this._feedbackNode["connect"](this._delayNode),this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._delayNode["delayTime"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._inputNode["disconnect"](),this._delayNode["disconnect"](),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._dryNode["disconnect"](),this._wetNode["disconnect"](),this._feedbackNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 6:this._params[1]=t/1e3,this.SetAudioParam(this._oscGainNode["gain"],t/1e3,i,s);break;case 7:this._params[2]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s);break;case 8:this._params[3]=t/100,this.SetAudioParam(this._feedbackNode["gain"],t/100,i,s)}}},self.C3AudioPhaserFX=class extends e{constructor(e,t,i,s,o,a,n){super(e),this._type="phaser",this._params=[t,i,s,o,a,n],this._inputNode=this.CreateGain(),this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-n/2,this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=n/2,this._filterNode=this._audioContext["createBiquadFilter"](),this._filterNode["type"]="allpass",this._filterNode["frequency"]["value"]=t,this._filterNode["detune"]["value"]=i,this._filterNode["Q"]["value"]=s,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=a,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=o,this._inputNode["connect"](this._filterNode),this._inputNode["connect"](this._dryNode),this._filterNode["connect"](this._wetNode),this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._filterNode["frequency"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._inputNode["disconnect"](),this._filterNode["disconnect"](),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._dryNode["disconnect"](),this._wetNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[5]=t,this.SetAudioParam(this._wetNode["gain"],t/2,i,s),this.SetAudioParam(this._dryNode["gain"],1-t/2,i,s);break;case 1:this._params[0]=t,this.SetAudioParam(this._filterNode["frequency"],t,i,s);break;case 2:this._params[1]=t,this.SetAudioParam(this._filterNode["detune"],t,i,s);break;case 3:this._params[2]=t,this.SetAudioParam(this._filterNode["Q"],t,i,s);break;case 6:this._params[3]=t,this.SetAudioParam(this._oscGainNode["gain"],t,i,s);break;case 7:this._params[4]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioGainFX=class extends e{constructor(e,t){super(e),this._type="gain",this._params=[t],this._node=this.CreateGain(),this._node["gain"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){const o=self.AudioDOMHandler.DbToLinear;if(4===e)this._params[0]=o(t),this.SetAudioParam(this._node["gain"],o(t),i,s)}},self.C3AudioStereoPanFX=class extends e{constructor(e,t){super(e),this._type="stereopan",this._params=[t],this._node=this._audioContext["createStereoPanner"](),this._node["pan"]["value"]=t}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){if(t=Math.min(Math.max(t/100,-1),1),9===e)this._params[0]=t,this.SetAudioParam(this._node["pan"],t,i,s)}},self.C3AudioTremoloFX=class extends e{constructor(e,t,i){super(e),this._type="tremolo",this._params=[t,i],this._node=this.CreateGain(),this._node["gain"]["value"]=1-i/2,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,this._oscGainNode=this.CreateGain(),this._oscGainNode["gain"]["value"]=i/2,this._oscNode["connect"](this._oscGainNode),this._oscGainNode["connect"](this._node["gain"]),this._oscNode["start"](0)}Release(){this._oscNode["stop"](0),this._oscNode["disconnect"](),this._oscGainNode["disconnect"](),this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._node["gain"],1-t/2,i,s),this.SetAudioParam(this._oscGainNode["gain"],t/2,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioRingModFX=class extends e{constructor(e,t,i){super(e),this._type="ringmod",this._params=[t,i],this._inputNode=this.CreateGain(),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=i,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-i,this._ringNode=this.CreateGain(),this._ringNode["gain"]["value"]=0,this._oscNode=this._audioContext["createOscillator"](),this._oscNode["frequency"]["value"]=t,this._oscNode["connect"](this._ringNode["gain"]),this._oscNode["start"](0),this._inputNode["connect"](this._ringNode),this._inputNode["connect"](this._dryNode),this._ringNode["connect"](this._wetNode)}Release(){this._oscNode["stop"](0),this._oscNode["disconnect"](),this._ringNode["disconnect"](),this._inputNode["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){switch(e){case 0:t=Math.max(Math.min(t/100,1),0),this._params[1]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s);break;case 7:this._params[0]=t,this.SetAudioParam(this._oscNode["frequency"],t,i,s)}}},self.C3AudioDistortionFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="distortion",this._params=[t,i,s,o,a],this._inputNode=this.CreateGain(),this._preGain=this.CreateGain(),this._postGain=this.CreateGain(),this._SetDrive(s,o),this._wetNode=this.CreateGain(),this._wetNode["gain"]["value"]=a,this._dryNode=this.CreateGain(),this._dryNode["gain"]["value"]=1-a,this._waveShaper=this._audioContext["createWaveShaper"](),this._curve=new Float32Array(65536),this._GenerateColortouchCurve(t,i),this._waveShaper.curve=this._curve,this._inputNode["connect"](this._preGain),this._inputNode["connect"](this._dryNode),this._preGain["connect"](this._waveShaper),this._waveShaper["connect"](this._postGain),this._postGain["connect"](this._wetNode)}Release(){this._inputNode["disconnect"](),this._preGain["disconnect"](),this._waveShaper["disconnect"](),this._postGain["disconnect"](),this._wetNode["disconnect"](),this._dryNode["disconnect"](),super.Release()}_SetDrive(e,t){e<.01&&(e=.01),this._preGain["gain"]["value"]=e,this._postGain["gain"]["value"]=Math.pow(1/e,.6)*t}_GenerateColortouchCurve(e,t){const i=32768;for(let s=0;s<i;++s){let o=s/i;o=this._Shape(o,e,t),this._curve[i+s]=o,this._curve[i-s-1]=-o}}_Shape(e,t,i){const s=1.05*i*t-t,o=e<0?-1:1,a=e<0?-e:e;let n=a<t?a:t+s*self.AudioDOMHandler.e4(a-t,1/s);return n*=o,n}ConnectTo(e){this._wetNode["disconnect"](),this._wetNode["connect"](e),this._dryNode["disconnect"](),this._dryNode["connect"](e)}GetInputNode(){return this._inputNode}SetParam(e,t,i,s){if(0===e)t=Math.max(Math.min(t/100,1),0),this._params[4]=t,this.SetAudioParam(this._wetNode["gain"],t,i,s),this.SetAudioParam(this._dryNode["gain"],1-t,i,s)}},self.C3AudioCompressorFX=class extends e{constructor(e,t,i,s,o,a){super(e),this._type="compressor",this._params=[t,i,s,o,a],this._node=this._audioContext["createDynamicsCompressor"](),this._node["threshold"]["value"]=t,this._node["knee"]["value"]=i,this._node["ratio"]["value"]=s,this._node["attack"]["value"]=o,this._node["release"]["value"]=a}Release(){this._node["disconnect"](),super.Release()}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}},self.C3AudioAnalyserFX=class extends e{constructor(e,t,i){super(e),this._type="analyser",this._params=[t,i],this._node=this._audioContext["createAnalyser"](),this._node["fftSize"]=t,this._node["smoothingTimeConstant"]=i,this._freqBins=new Float32Array(this._node["frequencyBinCount"]),this._signal=new Uint8Array(t),this._peak=0,this._rms=0,this._audioDomHandler._AddAnalyser(this)}Release(){this._audioDomHandler._RemoveAnalyser(this),this._node["disconnect"](),super.Release()}Tick(){this._node["getFloatFrequencyData"](this._freqBins),this._node["getByteTimeDomainData"](this._signal);const e=this._node["fftSize"];this._peak=0;let t=0;for(let i=0;i<e;++i){let e=(this._signal[i]-128)/128;e<0&&(e=-e),this._peak<e&&(this._peak=e),t+=e*e}const i=self.AudioDOMHandler.LinearToDb;this._peak=i(this._peak),this._rms=i(Math.sqrt(t/e))}ConnectTo(e){this._node["disconnect"](),this._node["connect"](e)}GetInputNode(){return this._node}SetParam(e,t,i,s){}GetData(){return{"tag":this.GetTag(),"index":this.GetIndex(),"peak":this._peak,"rms":this._rms,"binCount":this._node["frequencyBinCount"],"freqBins":this._freqBins}}}}

// start-export.js
"use strict";if(window["C3_IsSupported"]){const e=true;window["c3_runtimeInterface"]=new self.RuntimeInterface({useWorker:e,workerMainUrl:"workermain.js",runtimeScriptList:["scripts/c3main.js"],scriptFolder:"scripts/",exportType:"windows-webview2"})}
